Plugin for formatting Julia code in (n)vim using JuliaFormatter.jl.
Use any plugin manager:
Plug 'kdheepak/JuliaFormatter.vim'
call dein#add('kdheepak/JuliaFormatter.vim')
Plugin 'kdheepak/JuliaFormatter.vim'
Open any Julia file, type :
to open the command prompt and type the following:
" format full file
:call JuliaFormatter#Format(0)
" format last/current selection
:call JuliaFormatter#Format(1)
You can remap this to a keyboard shortcut as well.
" normal mode mapping
nnoremap <localleader>jf :<C-u>call JuliaFormatter#Format(0)<CR>
" visual mode mapping
vnoremap <localleader>jf :<C-u>call JuliaFormatter#Format(1)<CR>
The (n)vim documentation recommends using <localleader>
for a filetype plugin, but feel free to use <leader>
or <localleader>
for this remap.
In (n)vim, both <leader>
and <localleader>
are set to the \
key by default.
To modify the formatting options can be modified by setting g:JuliaFormatter_options
in your vimrc
. An example of this is:
let g:JuliaFormatter_options = {
\ 'indent' : 4,
\ 'margin' : 92,
\ 'always_for_in' : v:false,
\ 'whitespace_typedefs' : v:false,
\ 'whitespace_ops_in_indices' : v:true,
\ }
See full list of options over on the JuliaFormatter API documentation.
See MINRC
before opening an issue.