Skip to content

Commit 1718e7d

Browse files
dkearnschrisbra
authored andcommitted
runtime(vim): Update base-syntax, improve ex-bang matching
Always match ex-bang explicitly rather than incidentally as the ! operator. fixes: #16221 closes: #16410 Signed-off-by: Doug Kearns <[email protected]> Signed-off-by: Christian Brabandt <[email protected]>
1 parent 1f045f3 commit 1718e7d

File tree

7 files changed

+43
-32
lines changed

7 files changed

+43
-32
lines changed

runtime/syntax/generator/vim.vim.base

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
" Language: Vim script
33
" Maintainer: Hirohito Higashi <h.east.727 ATMARK gmail.com>
44
" Doug Kearns <[email protected]>
5-
" Last Change: 2024 Dec 21
5+
" Last Change: 2025 Jan 09
66
" Former Maintainer: Charles E. Campbell
77

88
" DO NOT CHANGE DIRECTLY.
@@ -26,7 +26,7 @@ syn keyword vimTodo contained COMBAK FIXME TODO XXX
2626
syn cluster vimCommentGroup contains=vimTodo,@Spell
2727

2828
" regular vim commands {{{2
29-
" GEN_SYN_VIM: vimCommand normal, START_STR='syn keyword vimCommand contained', END_STR=''
29+
" GEN_SYN_VIM: vimCommand normal, START_STR='syn keyword vimCommand contained', END_STR='nextgroup=vimBang'
3030

3131
" Lower priority for _new_ to distinguish constructors from the command.
3232
syn match vimCommand contained "\<new\>(\@!"
@@ -205,7 +205,7 @@ syn case match
205205
syn cluster vimCmdList contains=vimAbb,vimAddress,vimAutoCmd,vimAugroup,vimBehave,vimCall,vimCatch,vimConst,vimDef,vimDefFold,vimDelcommand,@vimEcho,vimEnddef,vimEndfunction,vimExecute,vimIsCommand,vimExtCmd,vimFor,vimFunction,vimFuncFold,vimGlobal,vimHighlight,vimLet,vimLoadkeymap,vimMap,vimMark,vimMatch,vimNotFunc,vimNormal,vimSet,vimSleep,vimSyntax,vimThrow,vimUnlet,vimUnmap,vimUserCmd,vimMenu,vimMenutranslate,@vim9CmdList
206206
syn cluster vim9CmdList contains=vim9Abstract,vim9Class,vim9Const,vim9Enum,vim9Export,vim9Final,vim9For,vim9Interface,vim9Type,vim9Var
207207
syn match vimCmdSep "[:|]\+" skipwhite nextgroup=@vimCmdList,vimSubst1
208-
syn match vimIsCommand "\<\%(\h\w*\|[23]mat\%[ch]\)\>" contains=vimCommand
208+
syn match vimIsCommand "\<\%(\h\w*\|[23]mat\%[ch]\)\>" nextgroup=vimBang contains=vimCommand
209209
syn match vimBang contained "!"
210210
syn match vimVar contained "\<\h[a-zA-Z0-9#_]*\>"
211211
syn match vimVar "\<[bwglstav]:\h[a-zA-Z0-9#_]*\>"
@@ -214,7 +214,6 @@ syn match vimVar "\s\zs&t_\S[a-zA-Z0-9]\>"
214214
syn match vimVar "\s\zs&t_k;"
215215
syn match vimFBVar contained "\<[bwglstav]:\h[a-zA-Z0-9#_]*\>"
216216
syn keyword vimCommand contained in
217-
syn match vimBang contained "!"
218217

219218
syn cluster vimExprList contains=vimEnvvar,vimFunc,vimNumber,vimOper,vimOperParen,vimLetRegister,vimString,vimVar,@vim9ExprList
220219
syn cluster vim9ExprList contains=vim9Boolean,vim9Null
@@ -282,7 +281,8 @@ syn keyword vimAugroupKey contained aug[roup] skipwhite nextgroup=vimAugroupBan
282281
" Operators: {{{2
283282
" =========
284283
syn cluster vimOperGroup contains=vimEnvvar,vimFunc,vimFuncVar,vimOper,vimOperParen,vimNumber,vimString,vimRegister,@vimContinue,vim9Comment,vimVar,vimBoolean,vimNull
285-
syn match vimOper "||\|&&\|[-+*/%.!]" skipwhite nextgroup=vimString,vimSpecFile
284+
syn match vimOper "\a\@<!!" skipwhite nextgroup=vimString,vimSpecFile
285+
syn match vimOper "||\|&&\|[-+*/%.]" skipwhite nextgroup=vimString,vimSpecFile
286286
syn match vimOper "\%#=1\(==\|!=\|>=\|<=\|=\~\|!\~\|>\|<\|=\|!\~#\)[?#]\{0,2}" skipwhite nextgroup=vimString,vimSpecFile
287287
syn match vimOper "\(\<is\|\<isnot\)[?#]\{0,2}\>" skipwhite nextgroup=vimString,vimSpecFile
288288
syn region vimOperParen matchgroup=vimParenSep start="(" end=")" contains=@vimOperGroup
@@ -558,8 +558,8 @@ syn region vimPatSepZone oneline contained matchgroup=vimPatSepZ start="\\%\
558558
syn region vimPatRegion contained transparent matchgroup=vimPatSepR start="\\[z%]\=(" end="\\)" contains=@vimSubstList oneline
559559
syn match vimNotPatSep contained "\\\\"
560560
syn cluster vimStringGroup contains=vimEscape,vimEscapeBrace,vimPatSep,vimNotPatSep,vimPatSepErr,vimPatSepZone,@Spell
561-
syn region vimString oneline keepend start=+[^a-zA-Z>!\\@]"+lc=1 skip=+\\\\\|\\"+ matchgroup=vimStringEnd end=+"+ contains=@vimStringGroup extend
562-
syn region vimString oneline keepend start=+[^a-zA-Z>!\\@]'+lc=1 end=+'+ extend
561+
syn region vimString oneline keepend start=+[^a-zA-Z>\\@]"+lc=1 skip=+\\\\\|\\"+ matchgroup=vimStringEnd end=+"+ contains=@vimStringGroup extend
562+
syn region vimString oneline keepend start=+[^a-zA-Z>\\@]'+lc=1 end=+'+ extend
563563
"syn region vimString oneline start="\s/\s*\A"lc=1 skip="\\\\\|\\+" end="/" contains=@vimStringGroup " see tst45.vim
564564
syn match vimString contained +"[^"]*\\$+ skipnl nextgroup=vimStringCont
565565
syn match vimStringCont contained +\(\\\\\|.\)\{-}[^\\]"+
@@ -681,10 +681,12 @@ endif
681681

682682
" Autocmd: {{{2
683683
" =======
684-
syn match vimAutoEventList contained "\(!\s\+\)\=\(\a\+,\)*\a\+" contains=vimAutoEvent nextgroup=vimAutoCmdSpace
684+
syn match vimAutoCmdBang contained "\a\@1<=!" skipwhite nextgroup=vimAutoEventList
685+
syn match vimAutoEventList contained "\%(\a\+,\)*\a\+" contains=vimAutoEvent nextgroup=vimAutoCmdSpace
685686
syn match vimAutoCmdSpace contained "\s\+" nextgroup=vimAutoCmdSfxList
686687
syn match vimAutoCmdSfxList contained "\S*" skipwhite nextgroup=vimAutoCmdMod,vimAutoCmdBlock
687-
syn keyword vimAutoCmd au[tocmd] do[autocmd] doautoa[ll] skipwhite nextgroup=vimAutoEventList
688+
syn keyword vimAutoCmd au[tocmd] skipwhite nextgroup=vimAutoCmdBang,vimAutoEventList
689+
syn keyword vimAutoCmd do[autocmd] doautoa[ll] skipwhite nextgroup=vimAutoEventList
688690
syn match vimAutoCmdMod "\(++\)\=\(once\|nested\)" skipwhite nextgroup=vimAutoCmdBlock
689691
syn region vimAutoCmdBlock contained matchgroup=vimSep start="{" end="}" contains=@vimDefBodyList
690692

@@ -1269,6 +1271,7 @@ if !exists("skip_vim_syntax_inits")
12691271
hi def link vimAugroupError vimError
12701272
hi def link vimAugroupKey vimCommand
12711273
hi def link vimAutoCmd vimCommand
1274+
hi def link vimAutoCmdBang vimBang
12721275
hi def link vimAutoEvent Type
12731276
hi def link vimAutoCmdMod Special
12741277
hi def link vimBang vimOper

runtime/syntax/testdir/dumps/vim_expr_01.dump

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717
|e+0#af5f00255&|c|h|o| +0#0000000&|'+0#e000002&|D|o|n|'@1|t| |h|i|g|h|l|i|g|h|t| |i|n|t|e|r|p|o|l|a|t|i|o|n|:| |{@1| |{|1| |+| |2|}| |}@1|'| +0#0000000&@22
1818
|e+0#af5f00255&|c|h|o| +0#0000000&|"+0#e000002&|D|o|n|'|t| |h|i|g|h|l|i|g|h|t| |i|n|t|e|r|p|o|l|a|t|i|o|n|:| |{@1| |{|1| |+| |2|}| |}@1|"| +0#0000000&@23
1919
|e+0#af5f00255&|c|h|o| +0#0000000&|$+0#e000002&|'|H|i|g|h|l|i|g|h|t| |i|n|t|e|r|p|o|l|a|t|i|o|n|:|\|t|{+0#e000e06&@1| +0#e000002&|{+0#e000e06&| +0#0000000&|s+0#00e0e07&|t|r|i|n|g|(+0#e000e06&|{|'+0#e000002&|f|o@1|'|:+0#0000000&| |'+0#e000002&|b|a|r|'|}+0#e000e06&|)| +0#0000000&|}+0#e000e06&| +0#e000002&|}+0#e000e06&@1|'+0#e000002&| +0#0000000&@8
20-
@57|1|5|,|1| @9|2|0|%|
20+
@57|1|5|,|1| @9|1|8|%|

runtime/syntax/testdir/dumps/vim_expr_02.dump

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717
@75
1818
|"+0#0000e05&| |O|c|t|a|l| +0#0000000&@67
1919
|e+0#af5f00255&|c|h|o| +0#0000000&@1|0+0#e000002&|3|7@1| +0#0000000&@64
20-
@57|3@1|,|1| @9|5|0|%|
20+
@57|3@1|,|1| @9|4|6|%|

runtime/syntax/testdir/dumps/vim_expr_03.dump

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717
|e+0#af5f00255&|c|h|o| +0#0000000&|5+0#e000002&@1|.|0| +0#0000000&@65
1818
|e+0#af5f00255&|c|h|o| +0#0000000&|-+0#af5f00255&|0+0#e000002&|.|1|2|3| +0#0000000&@63
1919
|e+0#af5f00255&|c|h|o| +0#0000000&|1+0#e000002&|.|2|3|4|e|0|3| +0#0000000&@61
20-
@57|5|1|,|1| @9|8|4|%|
20+
@57|5|1|,|1| @9|7@1|%|

runtime/syntax/testdir/dumps/vim_expr_04.dump

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
|e+0#af5f00255&|c|h|o| +0#0000000&|0+0#e000002&|z|F@1|0@1|E|D|0|1|5|D|A|F| +0#0000000&@55
88
|e+0#af5f00255&|c|h|o| +0#0000000&|0+0#e000002&|z|F@1|0@1|.|E|D|0|1|.|5|D|A|F| +0#0000000&@53
99
|e+0#af5f00255&|c|h|o| +0#0000000&|0+0#e000002&|z|F@1|.|0@1|.|E|D|.|0|1|.|5|D|.|A|F| +0#0000000&@50
10+
@75
11+
@75
12+
|"+0#0000e05&| |I|s@1|u|e| |#|1|6|2@1|1| |(|v|i|m|S|t|r|i|n|g| |b|e|c|o|m|e|s| |v|i|m|V|a|r| |w|h|e|n| |p|r|e|c|e|d|e|d| |b|y| |!|)| +0#0000000&@14
13+
|l+0#af5f00255&|e|t| +0#0000000&|b+0#00e0e07&|a|r| +0#0000000&|=+0#af5f00255&| +0#0000000&|!+0#af5f00255&|'+0#e000002&|g|:|b|a|r|'|-+0#af5f00255&|>|e+0#00e0e07&|x|i|s|t|s|(+0#e000e06&|)| +0#0000000&@46
14+
@75
1015
|~+0#4040ff13&| @73
1116
|~| @73
1217
|~| @73
1318
|~| @73
1419
|~| @73
15-
|~| @73
16-
|~| @73
17-
|~| @73
18-
|~| @73
19-
|~| @73
2020
| +0#0000000&@56|6|9|,|1| @9|B|o|t|

runtime/syntax/testdir/input/vim_expr.vim

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,8 @@ echo 0z
7070
echo 0zFF00ED015DAF
7171
echo 0zFF00.ED01.5DAF
7272
echo 0zFF.00.ED.01.5D.AF
73+
74+
75+
" Issue #16221 (vimString becomes vimVar when preceded by !)
76+
let bar = !'g:bar'->exists()
77+

0 commit comments

Comments
 (0)