diff --git a/site-modules/core/files/vim/init.vim b/site-modules/core/files/vim/init.vim index 1d430a3..4e6ac44 100644 --- a/site-modules/core/files/vim/init.vim +++ b/site-modules/core/files/vim/init.vim @@ -75,8 +75,3 @@ let g:CommandTWildIgnore="*/node_modules/*,*/vendor/*,*/runtime/*,*/public_html/ " Required for complietion with nvim-cmp set completeopt=menu,menuone,noselect -" Format code on save -augroup fmt - autocmd! - autocmd BufWritePre * undojoin | Neoformat -augroup END diff --git a/site-modules/core/files/vim/plugin/fmt.vim b/site-modules/core/files/vim/plugin/fmt.vim new file mode 100644 index 0000000..fd5c87b --- /dev/null +++ b/site-modules/core/files/vim/plugin/fmt.vim @@ -0,0 +1,17 @@ +" +" 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:fmt_on_save_enable() + augroup aa_fmt + autocmd! + autocmd BufWritePre * undojoin | Neoformat + 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()