1
0
Fork 0
mirror of https://github.com/luzifer/vim.git synced 2024-11-09 16:10:00 +00:00

Automatically execute shfmt on shell script save

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2018-10-15 11:34:06 +02:00
parent 2fff453c3b
commit 3d2466581a
Signed by: luzifer
GPG key ID: DC2729FDD34BE99E
2 changed files with 11 additions and 0 deletions

10
after/plugin/shfmt.vim Normal file
View file

@ -0,0 +1,10 @@
if exists('g:loaded_shfmt_wrapper')
finish
endif
let g:loaded_shfmt_wrapper = 1
function! SHFmt()
let save_pos = getpos(".")
execute "%!shfmt -s"
call setpos(".", save_pos)
endfunction

1
vimrc
View file

@ -1025,6 +1025,7 @@ let g:go_autodetect_gopath = 0
" "
au BufWritePre *.py,*.js :Autoformat au BufWritePre *.py,*.js :Autoformat
au FileType sh au BufWritePre <buffer> :call SHFmt()
" "
" Custom commands " Custom commands