From dd7b0fd2a55dd7a355aedd5d14dd4c9126b0fe93 Mon Sep 17 00:00:00 2001 From: Talha Qamar Date: Mon, 30 Sep 2024 08:10:18 +0500 Subject: [PATCH] formatting now doesn't mess with cursor position --- ftplugin/hblang.vim | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ftplugin/hblang.vim b/ftplugin/hblang.vim index 2e07215..1753262 100644 --- a/ftplugin/hblang.vim +++ b/ftplugin/hblang.vim @@ -1,16 +1,18 @@ setlocal commentstring=//\ %s -function Hbformat() +function HBformat() silent! !hbc --fmt-stdout if v:shell_error echom "Errors in file" !hbc --fmt-stdout else + let save_cursor = getcurpos() silent! %!hbc --fmt-stdout + call setpos('.', save_cursor) endif endfunction augroup hblang_group autocmd! - autocmd BufWritePost *.hb :call Hbformat() + autocmd BufWritePost *.hb :call HBformat() augroup END