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

Conversation

atweiden
Copy link
Contributor

@atweiden atweiden commented Nov 19, 2022

Set g:zig_fmt_autoswitch to 0 in your vimrc to disable automatically switching to the location list if/when zig fmt encounters code formatting errors.

When set to 0, g:zig_fmt_autoswitch configures the Vim cursor to remain where it was prior to running zig fmt. The location list — which gets populated with code formatting errors as per normal — can then be viewed at a glance, without losing focus.

Either don’t set g:zig_fmt_autoswitch at all, or set it to 1, to keep the current behaviour of this plugin.

```vim
" don't automatically switch to location list if zig fmt encounters errors
let g:zig_fmt_autoswitch = 0
```
@atweiden atweiden changed the title [RFC] Remain in main window upon zig fmt error instead of switching to quickfix window [RFC] g:zig_fmt_autoswitch: Configure automatic switching to location list upon zig fmt error Dec 5, 2022
@atweiden atweiden changed the title [RFC] g:zig_fmt_autoswitch: Configure automatic switching to location list upon zig fmt error g:zig_fmt_autoswitch: Configure automatic switching to location list upon zig fmt error Dec 5, 2022
@idbrii
Copy link

idbrii commented Dec 21, 2023

I think the logic would be clearer if the call to wincmd p was right after lwindow. Then you don't need the if or multiple points of return.

@atweiden
Copy link
Contributor Author

Can you provide example code? I’m open to making that change, but I don’t see how to restrict calling wincmd p without a conditional check of the err variable. For example, after setting g:zig_fmt_autoswitch to 0, this would result in calling wincmd p even if no location list were present:

execute 'silent! lwindow ' . win_height
if !get(g:, 'zig_fmt_autoswitch', 1)
  wincmd p
endif

I also don’t see what to do with the echohl Error line without conditionally checking the err variable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants