Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

g:zig_fmt_autoswitch: Configure automatic switching to location list upon zig fmt error #82

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ This plugin enables automatic code formatting on save by default using
let g:zig_fmt_autosave = 0
```

If `zig fmt` encounters a code formatting error, this plugin populates
the location list with relevant errors. To disable automatically switching
to the location list, use this configuration in vimrc:

```
let g:zig_fmt_autoswitch = 0
```

The default compiler which gets used by `:make` (`:help :compiler` for details)
is `zig_build` and it runs `zig build`. The other options are:
* `:compiler zig_test` which runs `zig test` on the current file.
Expand Down
7 changes: 6 additions & 1 deletion autoload/zig/fmt.vim
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,12 @@ function! zig#fmt#Format() abort

if err != 0
echohl Error | echomsg "zig fmt returned error" | echohl None
return
if get(g:, 'zig_fmt_autoswitch', 1)
return
else
wincmd p
return
endif
endif

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