summaryrefslogtreecommitdiffhomepage
path: root/.exrc
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2024-08-08 01:04:31 +0200
committerThomas Voss <mail@thomasvoss.com> 2024-08-08 01:04:31 +0200
commita02a4f2765a3916ba8242d9919244dc12624e5b7 (patch)
tree25a5feb5accf5e879be77594cfde8b86f816bf34 /.exrc
parent07d690e540e891bf3d0d0e8058a0cf8b011df8bd (diff)
Autoformat Go and Templ code on save
Diffstat (limited to '.exrc')
-rw-r--r--.exrc9
1 files changed, 9 insertions, 0 deletions
diff --git a/.exrc b/.exrc
index 5682015..c1f065a 100644
--- a/.exrc
+++ b/.exrc
@@ -1 +1,10 @@
+function s:SaveExcursion(cmd)
+ let l:win = winsaveview()
+ execute '%!' .. a:cmd
+ call winrestview(l:win)
+endfunction
+
+autocmd BufWritePre *.go call s:SaveExcursion('gofmt -s')
+autocmd BufWritePre *.templ call s:SaveExcursion('templ fmt')
+
let g:netrw_list_hide .= ',.*_templ.go$'