9
15
Fork
You've already forked zig.vim
2

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

Open
atweiden wants to merge 1 commit from atweiden/wincmd-p-after-zigfmt into master
pull from: atweiden/wincmd-p-after-zigfmt
merge into: ziglang:master
ziglang:master
ziglang:hb/new-keywords
ziglang:mikdusan-zir
atweiden commented 2022年11月19日 03:33:05 +01:00 (Migrated from github.com)
Copy link

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.

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.
idbrii commented 2023年12月21日 22:53:23 +01:00 (Migrated from github.com)
Copy link

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.

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 commented 2023年12月28日 02:55:37 +01:00 (Migrated from github.com)
Copy link

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.

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: ```vim 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.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin atweiden/wincmd-p-after-zigfmt:atweiden/wincmd-p-after-zigfmt
git switch atweiden/wincmd-p-after-zigfmt
Sign in to join this conversation.
No reviewers
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ziglang/zig.vim!82
Reference in a new issue
ziglang/zig.vim
No description provided.
Delete branch "atweiden/wincmd-p-after-zigfmt"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?