formatting now doesn't mess with cursor position

This commit is contained in:
Talha Qamar 2024-09-30 08:10:18 +05:00
parent 46b7b8db45
commit dd7b0fd2a5

View file

@ -1,16 +1,18 @@
setlocal commentstring=//\ %s
function Hbformat()
function HBformat()
silent! !hbc --fmt-stdout <afile>
if v:shell_error
echom "Errors in file"
!hbc --fmt-stdout <afile>
else
let save_cursor = getcurpos()
silent! %!hbc --fmt-stdout <afile>
call setpos('.', save_cursor)
endif
endfunction
augroup hblang_group
autocmd!
autocmd BufWritePost *.hb :call Hbformat()
autocmd BufWritePost *.hb :call HBformat()
augroup END