1
0
mirror of https://github.com/luzifer/vim.git synced 2024-09-19 11:02:55 +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 FileType sh au BufWritePre <buffer> :call SHFmt()
"
" Custom commands