Skip to content

Commit 208b1bd

Browse files
committed
g:zig_fmt_autoswitch: cfg location list autoswitch
```vim " don't automatically switch to location list if zig fmt encounters errors let g:zig_fmt_autoswitch = 0 ```
1 parent c33e1e3 commit 208b1bd

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ This plugin enables automatic code formatting on save by default using
3737
let g:zig_fmt_autosave = 0
3838
```
3939

40+
If `zig fmt` encounters a code formatting error, this plugin populates
41+
the location list with relevant errors. To disable automatically switching
42+
to the location list, use this configuration in vimrc:
43+
44+
```
45+
let g:zig_fmt_autoswitch = 0
46+
```
47+
4048
The default compiler which gets used by `:make` (`:help :compiler` for details)
4149
is `zig_build` and it runs `zig build`. The other options are:
4250
* `:compiler zig_test` which runs `zig test` on the current file.

autoload/zig/fmt.vim

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,12 @@ function! zig#fmt#Format() abort
6969

7070
if err != 0
7171
echohl Error | echomsg "zig fmt returned error" | echohl None
72-
return
72+
if get(g:, 'zig_fmt_autoswitch', 1)
73+
return
74+
else
75+
wincmd p
76+
return
77+
endif
7378
endif
7479

7580
" Run the syntax highlighter on the updated content and recompute the folds if

0 commit comments

Comments
 (0)