Dotfiles/site-modules/core/files/vim/plugin/fmt.vim
Ade Attwood 6022083000 chore(vim): format csharp files with the lsp
This will be using `dotnet format` under the hood and take any settings from
the editorconfig. The advantage of this is it will only do the file, with
`dotnet format` you need todo the hole solution.
2025-01-21 08:24:34 +00:00

25 lines
631 B
VimL

"
" Functions to toggle format on save with Neoformat. This is off by default so
" I don't accidentally start formatting when rebasing (bad memories).
function s:format_on_save()
if &filetype == 'fsharp' || &filetype == 'cs'
return execute('lua vim.lsp.buf.format()')
endif
undojoin | Neoformat
endfunction
function s:fmt_on_save_enable()
augroup aa_fmt
autocmd!
autocmd BufWritePre * call s:format_on_save()
augroup END
endfunction
function s:fmt_on_save_disable()
autocmd! aa_fmt
endfunction
command! FMTOnSaveEnable call s:fmt_on_save_enable()
command! FMTOnSaveDisable call s:fmt_on_save_disable()