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

runtime(vim): correctly handle ! attribute for augroup/doautocmd/doautoall #14906

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

chrisbra
Copy link
Member

@chrisbra chrisbra commented Jun 3, 2024

I noticed that

:autocmd! FooBar
:augroup! FooBar

looks slightly different to how the ! is drawn. While the ! for the autocmd case is shown in the same color as autocmd, for :augroup is is shown as VimEventList

In addition, the vim syntax seems to accept doautocmd! and doautoall! (with bang attribute) even so this is not valid.

So let's fix all of those and mark the ! as an error for the the :doautocmd/doautoall case.

cc @dkearns

…toall

I noticed that
```
:autocmd! FooBar
:augroup! FooBar
```

looks slightly different to how the ! is drawn. While the `!` for the
autocmd case is shown in the same color as autocmd, for :augroup is is
shown as VimEventList

In addition, the vim syntax seems to accept doautocmd! and doautoall!
(with bang attribute) even so this is not valid.

So let's fix all of those and mark the ! as an error for the the
:doautocmd/doautoall case.

Signed-off-by: Christian Brabandt <[email protected]>
@chrisbra chrisbra changed the title runtime(vim): correctly handle ! attrubute for augroup/doautocmd/doau… runtime(vim): correctly handle ! attribute for augroup/doautocmd/doautoall Jun 3, 2024
@dkearns
Copy link
Contributor

dkearns commented Jun 4, 2024

Thanks. We need to match vimAutoEventList after a ! so I'd add a dedicated bang group for autocmds like the following.

--- vim.vim     2024-06-04 13:18:27.530178121  1000
    /tmp/vim2.vim       2024-06-04 20:20:11.472645559  1000
@@ -565,8  565,9 @@
 if !exists("g:vimsyn_noerror")
  syn match     vimAutoBangError        contained       "!"     skipwhite nextgroup=vimAutoEventList
 endif
-syn keyword    vimAutoCmd      au[tocmd]       skipwhite       nextgroup=vimAugroupBang,vimAutoEventList
 syn keyword    vimAutoCmd      au[tocmd]       skipwhite       nextgroup=vimAutoCmdBang,vimAutoEventList
 syn keyword    vimAutoCmd      do[autocmd] doautoa[ll] skipwhite nextgroup=vimAutoBangError,vimAutoEventList
 syn match      vimAutoCmdBang  contained       "\a\@1<=!"      skipwhite nextgroup=vimAutoEventList
 syn match      vimAutoCmdMod   "\(  \)\=\(once\|nested\)"      skipwhite nextgroup=vimAutoCmdBlock
 syn region     vimAutoCmdBlock contained       matchgroup=vimSep start="{" end="}" contains=@vimDefBodyList
 
@@ -1106,6  1107,7 @@
  hi def link vimAugroupError   vimError
  hi def link vimAugroupKey     vimCommand
  hi def link vimAutoCmd        vimCommand
  hi def link vimAutoCmdBang    vimBang
  hi def link vimAutoEvent      Type
  hi def link vimAutoCmdMod     Special
  hi def link vimBang   vimOper

Patch on top of your changes.

@dkearns
Copy link
Contributor

dkearns commented Jun 4, 2024

I also found a stash attempting to fix a number of issues with :au. I'll see what I can salvage...

@chrisbra
Copy link
Member Author

chrisbra commented Jun 5, 2024

do you want to take over this one then? Or shall I squash your patch on top of mine and go ahead merging?

@dkearns
Copy link
Contributor

dkearns commented Jun 10, 2024

I can take it if you're not in a hurry for the intermediate fix.

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.

None yet

2 participants