Closed soulshake closed 6 years ago
I did get this working but never committed/documented it. I'll take another look in to it when I can find some free time.
@soulshake sorry it took a while, can you please let me know if it works OK for you?
let g:shfmt_fmt_on_save = 1
I've also standardised the variable naming so if you were usingvimshfmt_extra_args
, please update to just shfmt_extra_args
.
It works! :tada:
I was using let g:shfmt_switches = ['-i 2']
in my .vimrc
. Once I replaced this with let g:shfmt_extra_args = '-i 2'
it worked as expected.
I'll use it for a while and let you know if I notice any unexpected behavior.
Thank you!
Excellent!
I’ll fix the README tomorrow, can’t belive I missed that!
Sorry to necrobump: for some reason here it's not working.
Maybe I'm stupid and I made some trivial mistake, but I simply put in my .vim/ftplugin/sh.vim
:
let g:shfmt_fmt_on_save = 1
augroup LocalShell
autocmd!
autocmd BufWritePre * Shfmt
augroup END
The first one alone it's not working, the second one yes (of course even alone).
Tested with both vim
and nvim
, the plugin has been installed with vim-plug
. If I'll try to fix I'll update as soon as I find something useful.
Thanks, this is a useful plugin!
It would be super awesome if this could (optionally) auto format when a file is saved, similar to
vim-terraform
'sg:terraform_fmt_on_save
.