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
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
9 changes: 7 additions & 2 deletions runtime/syntax/generator/vim.vim.base
Original file line number Diff line number Diff line change
Expand Up @@ -519,10 519,14 @@ syn keyword vimFor for skipwhite nextgroup=vimVar,vimVarList

" Autocmd: {{{2
" =======
syn match vimAutoEventList contained "\(!\s\ \)\=\(\a\ ,\)*\a\ " contains=vimAutoEvent nextgroup=vimAutoCmdSpace
syn match vimAutoEventList contained "\(\a\ ,\)*\a\ " contains=vimAutoEvent nextgroup=vimAutoCmdSpace
syn match vimAutoCmdSpace contained "\s\ " nextgroup=vimAutoCmdSfxList
syn match vimAutoCmdSfxList contained "\S*" skipwhite nextgroup=vimAutoCmdMod,vimAutoCmdBlock
syn keyword vimAutoCmd au[tocmd] do[autocmd] doautoa[ll] skipwhite nextgroup=vimAutoEventList
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 do[autocmd] doautoa[ll] skipwhite nextgroup=vimAutoBangError,vimAutoEventList
syn match vimAutoCmdMod "\( \)\=\(once\|nested\)" skipwhite nextgroup=vimAutoCmdBlock
syn region vimAutoCmdBlock contained matchgroup=vimSep start="{" end="}" contains=@vimDefBodyList

Expand Down Expand Up @@ -1047,6 1051,7 @@ if !exists("skip_vim_syntax_inits")
hi def link vimSubstFlagErr vimError
hi def link vimSynCaseError vimError
hi def link vimSynFoldMethodError vimError
hi def link vimAutoBangError vimError
hi def link vimBufnrWarn vimWarn
endif

Expand Down
2 changes: 1 addition & 1 deletion runtime/syntax/testdir/dumps/vim_ex_augroup_00.dump
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 17,4 @@
|" 0#0000e05&| |l|i|s|t| |g|r|o|u|p|s| 0#0000000&@61
|a 0#af5f00255&|u|g|r|o|u|p| 0#0000000&@67
@75
@57|1|,|1| @10|A|l@1|
@57|1|,|1| @10|T|o|p|
20 changes: 20 additions & 0 deletions runtime/syntax/testdir/dumps/vim_ex_augroup_01.dump
Original file line number Diff line number Diff line change
@@ -0,0 1,20 @@
|a 0#af5f00255#ffffff0|u|g|r|o|u|p| 0#0000000&|!|@|#|$|%|^|&|*|(|)|_| | ||| |a 0#af5f00255&|u|t|o|c|m|d|!| 0#0000000&||| |a 0#af5f00255&|u|g|r|o|u|p| 0#0000000&|E|N|D| @29
|a 0#af5f00255&|u|g|r|o|u|p|!| 0#0000000&|!|@|#|$|%|^|&|*|(|)|_| | @53
@75
|" 0#0000e05&| |l|i|s|t| |g|r|o|u|p|s| 0#0000000&@61
|a 0#af5f00255&|u|g|r|o|u|p| 0#0000000&@67
> @74
|" 0#0000e05&| |b|a|n|g| |i|s| |a|n| |e|r@1|o|r| |f|o|r| |d|o|a|u|t|o|c|m|d| |a|n|d| |d|o|a|u|t|o|a|l@1| 0#0000000&@28
|a 0#af5f00255&|u|g|r|o|u|p|!| 0#0000000&|f|o@1|b|a|r| @59
|a 0#af5f00255&|u|t|o|c|m|d|!| 0#0000000&|f|o@1|b|a|r| @59
@75
|d 0#af5f00255&|o|a|u|t|o|c|m|d|! 0#ffffff16#ff404010| 0#0000000#ffffff0|F 0#00e0003&|i|l|e|T|y|p|e|, 0#0000000&|B 0#00e0003&|u|f|E|n|t|e|r| 0#0000000&@46
|d 0#af5f00255&|o|a|u|t|o|a|l@1|! 0#ffffff16#ff404010| 0#0000000#ffffff0|B 0#00e0003&|u|f|W|i|n|E|n|t|e|r|, 0#0000000&|W 0#00e0003&|i|n|E|n|t|e|r| 0#0000000&@43
|~ 0#4040ff13&| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
| 0#0000000&@56|1|9|,|0|-|1| @7|B|o|t|
18 changes: 9 additions & 9 deletions runtime/syntax/testdir/dumps/vim_ex_augroup_99.dump
Original file line number Diff line number Diff line change
@@ -1,10 1,4 @@
|" 0#0000e05#ffffff0| |V|i|m| |:|a|u|g|r|o|u|p| |c|o|m@1|a|n|d| 0#0000000&@52
@75
|a 0#af5f00255&|u|g|r|o|u|p| 0#0000000&|f|o@1| @63
@2|a 0#af5f00255&|u|t|o|c|m|d| 0#0000000&|B 0#00e0003&|u|f|R|e|a|d| 0#0000000&|*| |e 0#af5f00255&|c|h|o|m|s|g| 0#0000000&|" 0#e000002&|F|o@1|"| 0#0000000&@41
|a 0#af5f00255&|u|g|r|o|u|p| 0#0000000&|E|N|D| @63
@75
|a 0#af5f00255&|u|g|r|o|u|p| 0#0000000&|f|o@1| ||| |a 0#af5f00255&|u|t|o|c|m|d|!| 0#0000000&||| |a 0#af5f00255&|u|g|r|o|u|p| 0#0000000&|E|N|D| @38
|a 0#af5f00255#ffffff0|u|g|r|o|u|p| 0#0000000&|f|o@1| ||| |a 0#af5f00255&|u|t|o|c|m|d|!| 0#0000000&||| |a 0#af5f00255&|u|g|r|o|u|p| 0#0000000&|E|N|D| @38
|a 0#af5f00255&|u|g|r|o|u|p|!| 0#0000000&|f|o@1| @62
@75
|a 0#af5f00255&|u|g|r|o|u|p| 0#0000000&|!|@|#|$|%|^|&|*|(|)|_| | @54
Expand All @@ -16,5 10,11 @@
@75
|" 0#0000e05&| |l|i|s|t| |g|r|o|u|p|s| 0#0000000&@61
|a 0#af5f00255&|u|g|r|o|u|p| 0#0000000&@67
> @74
@57|1|9|,|0|-|1| @7|A|l@1|
@75
|" 0#0000e05&| |b|a|n|g| |i|s| |a|n| |e|r@1|o|r| |f|o|r| |d|o|a|u|t|o|c|m|d| |a|n|d| |d|o|a|u|t|o|a|l@1| 0#0000000&@28
|a 0#af5f00255&|u|g|r|o|u|p|!| 0#0000000&|f|o@1|b|a|r| @59
|a 0#af5f00255&|u|t|o|c|m|d|!| 0#0000000&|f|o@1|b|a|r| @59
@75
|d 0#af5f00255&|o|a|u|t|o|c|m|d|! 0#ffffff16#ff404010| 0#0000000#ffffff0|F 0#00e0003&|i|l|e|T|y|p|e|, 0#0000000&|B 0#00e0003&|u|f|E|n|t|e|r| 0#0000000&@46
>d 0#af5f00255&|o|a|u|t|o|a|l@1|! 0#ffffff16#ff404010| 0#0000000#ffffff0|B 0#00e0003&|u|f|W|i|n|E|n|t|e|r|, 0#0000000&|W 0#00e0003&|i|n|E|n|t|e|r| 0#0000000&@43
@57|2|5|,|1| @9|B|o|t|
6 changes: 6 additions & 0 deletions runtime/syntax/testdir/input/vim_ex_augroup.vim
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 17,9 @@ augroup! !@#$%^&*()_
" list groups
augroup

" bang is an error for doautocmd and doautoall
augroup! foobar
autocmd! foobar

doautocmd! FileType,BufEnter
doautoall! BufWinEnter,WinEnter
11 changes: 8 additions & 3 deletions runtime/syntax/vim.vim
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 3,7 @@
" Maintainer: Hirohito Higashi <h.east.727 ATMARK gmail.com>
" Doug Kearns <[email protected]>
" URL: https://github.com/vim-jp/syntax-vim-ex
" Last Change: 2024 May 27
" Last Change: 2024 Jun 03
" Former Maintainer: Charles E. Campbell

" DO NOT CHANGE DIRECTLY.
Expand Down Expand Up @@ -559,10 559,14 @@ syn keyword vimAbb abc[lear] cabc[lear] iabc[lear] skipwhite nextgroup=vimMapMod

" Autocmd: {{{2
" =======
syn match vimAutoEventList contained "\(!\s\ \)\=\(\a\ ,\)*\a\ " contains=vimAutoEvent nextgroup=vimAutoCmdSpace
syn match vimAutoEventList contained "\(\a\ ,\)*\a\ " contains=vimAutoEvent nextgroup=vimAutoCmdSpace
syn match vimAutoCmdSpace contained "\s\ " nextgroup=vimAutoCmdSfxList
syn match vimAutoCmdSfxList contained "\S*" skipwhite nextgroup=vimAutoCmdMod,vimAutoCmdBlock
syn keyword vimAutoCmd au[tocmd] do[autocmd] doautoa[ll] skipwhite nextgroup=vimAutoEventList
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 do[autocmd] doautoa[ll] skipwhite nextgroup=vimAutoBangError,vimAutoEventList
syn match vimAutoCmdMod "\( \)\=\(once\|nested\)" skipwhite nextgroup=vimAutoCmdBlock
syn region vimAutoCmdBlock contained matchgroup=vimSep start="{" end="}" contains=@vimDefBodyList

Expand Down Expand Up @@ -1091,6 1095,7 @@ if !exists("skip_vim_syntax_inits")
hi def link vimSubstFlagErr vimError
hi def link vimSynCaseError vimError
hi def link vimSynFoldMethodError vimError
hi def link vimAutoBangError vimError
hi def link vimBufnrWarn vimWarn
endif

Expand Down
Loading