feat(vim): use the lsp to format f# files
For formatting f# there really is only one tool, fantomas. The CLI for fantomas has no input and will only do files. Ionide has built in support for fantomas, we need some extra config to make this work because right now we are only using Neoformat for formatting. This updates the formatting function to format with the lsp only for f# files. Anything else it will fall back to usign Neoformat. I am hoping that there will not be many cases of this and we can continue to use Neoformat.
This commit is contained in:
parent
63edfe28ce
commit
22eda7e6ed
1 changed files with 9 additions and 1 deletions
|
|
@ -2,10 +2,18 @@
|
||||||
" Functions to toggle format on save with Neoformat. This is off by default so
|
" Functions to toggle format on save with Neoformat. This is off by default so
|
||||||
" I don't accidentally start formatting when rebasing (bad memories).
|
" I don't accidentally start formatting when rebasing (bad memories).
|
||||||
|
|
||||||
|
function s:format_on_save()
|
||||||
|
if &filetype == 'fsharp'
|
||||||
|
return execute('lua vim.lsp.buf.format()')
|
||||||
|
endif
|
||||||
|
|
||||||
|
undojoin | Neoformat
|
||||||
|
endfunction
|
||||||
|
|
||||||
function s:fmt_on_save_enable()
|
function s:fmt_on_save_enable()
|
||||||
augroup aa_fmt
|
augroup aa_fmt
|
||||||
autocmd!
|
autocmd!
|
||||||
autocmd BufWritePre * undojoin | Neoformat
|
autocmd BufWritePre * call s:format_on_save()
|
||||||
augroup END
|
augroup END
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue