Skip to content

Commit 97501af

Browse files
dkearnschrisbra
authored andcommitted
runtime(vim): Update base syntax, match "any" type distinctly
Allow for special highlighting of the "any" Vim9 type. Addresses comment vim/vim#17722 (comment) closes: #17769 Signed-off-by: Doug Kearns <dougkearns@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
1 parent 138381b commit 97501af

4 files changed

Lines changed: 55 additions & 10 deletions

File tree

runtime/syntax/generator/vim.vim.base

Lines changed: 9 additions & 5 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 <dougkearns@gmail.com>
5-
" Last Change: 2025 Jul 11
5+
" Last Change: 2025 Jul 17
66
" Former Maintainer: Charles E. Campbell
77

88
" DO NOT CHANGE DIRECTLY.
@@ -544,14 +544,15 @@ syn region vimReturnType contained
544544
syn match vimParamType contained ":\s" skipwhite skipnl nextgroup=@vimType contains=vimTypeSep
545545

546546
syn match vimTypeSep contained ":\%(\s\|\n\)\@=" skipwhite nextgroup=@vimType
547-
syn keyword vimType contained any blob bool channel float job number string void
547+
syn keyword vimType contained blob bool channel float job number string void
548+
syn keyword vimTypeAny contained any
548549
syn match vimType contained "\<\%(func\)\>"
549550
syn region vimCompoundType contained matchgroup=vimType start="\<func(" end=")" nextgroup=vimTypeSep contains=@vim9Continue,@vimType transparent
550551
syn region vimCompoundType contained matchgroup=vimType start="\<tuple<" end=">" contains=@vim9Continue,@vimType transparent
551552
syn region vimCompoundType contained matchgroup=vimType start="\<\%(list\|dict\)<" end=">" contains=@vimType oneline transparent
552553
syn match vimUserType contained "\<\%(\h\w*\.\)*\u\w*\>"
553554

554-
syn cluster vimType contains=vimType,vimCompoundType,vimUserType
555+
syn cluster vimType contains=vimType,vimTypeAny,vimCompoundType,vimUserType
555556

556557
" Classes, Enums And Interfaces: {{{2
557558
" =============================
@@ -1063,7 +1064,8 @@ syn match vim9Variable contained "\<\h\w*\>" skipwhite nextgroup=vim9VariableTyp
10631064
syn region vim9VariableList contained start="\[" end="]" contains=@vimContinue,@vimSpecialVar,vim9Variable skipwhite nextgroup=vimLetHeredoc
10641065

10651066
syn match vim9VariableTypeSep contained "\S\@1<=:\%(\s\|\n\)\@=" skipwhite nextgroup=@vim9VariableType
1066-
syn keyword vim9VariableType contained any blob bool channel float job number string void skipwhite nextgroup=vimLetHeredoc
1067+
syn keyword vim9VariableType contained blob bool channel float job number string void skipwhite nextgroup=vimLetHeredoc
1068+
syn keyword vim9VariableTypeAny contained any skipwhite nextgroup=vimLetHeredoc
10671069
syn match vim9VariableType contained "\<\%(func\)\>" skipwhite nextgroup=vimLetHeredoc
10681070
syn region vim9VariableCompoundType contained
10691071
\ matchgroup=vim9VariableType
@@ -1089,7 +1091,7 @@ syn region vim9VariableCompoundType contained
10891091
\ transparent
10901092
syn match vim9VariableUserType contained "\<\%(\h\w*\.\)*\u\w*\>" skipwhite nextgroup=vimLetHeredoc
10911093

1092-
syn cluster vim9VariableType contains=vim9VariableType,vim9VariableCompoundType,vim9VariableUserType
1094+
syn cluster vim9VariableType contains=vim9VariableType,vim9VariableTypeAny,vim9VariableCompoundType,vim9VariableUserType
10931095

10941096
" Lockvar and Unlockvar: {{{2
10951097
" =====================
@@ -2424,6 +2426,7 @@ if !exists("skip_vim_syntax_inits")
24242426
hi def link vimThrow vimCommand
24252427
hi def link vimTodo Todo
24262428
hi def link vimType Type
2429+
hi def link vimTypeAny vimType
24272430
hi def link vimUniq vimCommand
24282431
hi def link vimUniqBang vimBang
24292432
hi def link vimUniqOptions Special
@@ -2514,6 +2517,7 @@ if !exists("skip_vim_syntax_inits")
25142517
hi def link vim9TypeEquals vimOper
25152518
hi def link vim9Variable vimVar
25162519
hi def link vim9VariableType vimType
2520+
hi def link vim9VariableTypeAny vimType
25172521
hi def link vim9Var vimCommand
25182522
hi def link vim9Vim9ScriptArg Special
25192523
hi def link vim9Vim9Script vimCommand
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
>v+0#af5f00255#ffffff0|i|m|9|s|c|r|i|p|t| +0#0000000&@64
2+
|#+0#0000e05&| |V|i|m|9| |t|y|p|e|s| +0#0000000&@62
3+
|#+0#0000e05&| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |h|i| |l|i|n|k| |v|i|m|T|y|p|e|A|n|y| |T|o|d|o| +0#0000000&@34
4+
|#+0#0000e05&| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |h|i| |l|i|n|k| |v|i|m|V|a|r|i|a|b|l|e|T|y|p|e|A|n|y| |T|o|d|o| +0#0000000&@26
5+
@75
6+
@75
7+
|#+0#0000e05&| |b|u|i|l|t|i|n| |t|y|p|e|s| |(|d|i|s|t|i|n|c|t| |a|n|y| |h|i|g|h|l|i|g|h|t|i|n|g|)| +0#0000000&@31
8+
@75
9+
|v+0#af5f00255&|a|r| +0#0000000&|f|o@1|:| |b+0#00e0003&|o@1|l| +0#0000000&@61
10+
|v+0#af5f00255&|a|r| +0#0000000&|b|a|r|:| |a+0#00e0003&|n|y| +0#0000000&@62
11+
@75
12+
|d+0#af5f00255&|e|f| +0#0000000&|F|o@1|(+0#e000e06&|a+0#0000000&|r|g|:| |b+0#00e0003&|o@1|l|)+0#e000e06&|:+0#0000000&| |b+0#00e0003&|o@1|l| +0#0000000&@50
13+
|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@68
14+
@75
15+
|d+0#af5f00255&|e|f| +0#0000000&|B|a|r|(+0#e000e06&|a+0#0000000&|r|g|:| |a+0#0000001#ffff4012|n|y|)+0#e000e06#ffffff0|:+0#0000000&| |a+0#0000001#ffff4012|n|y| +0#0000000#ffffff0@52
16+
|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@68
17+
@75
18+
|~+0#4040ff13&| @73
19+
|~| @73
20+
| +0#0000000&@56|1|,|1| @10|A|l@1|
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
vim9script
2+
# Vim9 types
3+
# VIM_TEST_SETUP hi link vimTypeAny Todo
4+
# VIM_TEST_SETUP hi link vimVariableTypeAny Todo
5+
6+
7+
# builtin types (distinct any highlighting)
8+
9+
var foo: bool
10+
var bar: any
11+
12+
def Foo(arg: bool): bool
13+
enddef
14+
15+
def Bar(arg: any): any
16+
enddef
17+

runtime/syntax/vim.vim

Lines changed: 9 additions & 5 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 <dougkearns@gmail.com>
5-
" Last Change: 2025 Jul 16
5+
" Last Change: 2025 Jul 17
66
" Former Maintainer: Charles E. Campbell
77

88
" DO NOT CHANGE DIRECTLY.
@@ -598,14 +598,15 @@ syn region vimReturnType contained
598598
syn match vimParamType contained ":\s" skipwhite skipnl nextgroup=@vimType contains=vimTypeSep
599599

600600
syn match vimTypeSep contained ":\%(\s\|\n\)\@=" skipwhite nextgroup=@vimType
601-
syn keyword vimType contained any blob bool channel float job number string void
601+
syn keyword vimType contained blob bool channel float job number string void
602+
syn keyword vimTypeAny contained any
602603
syn match vimType contained "\<\%(func\)\>"
603604
syn region vimCompoundType contained matchgroup=vimType start="\<func(" end=")" nextgroup=vimTypeSep contains=@vim9Continue,@vimType transparent
604605
syn region vimCompoundType contained matchgroup=vimType start="\<tuple<" end=">" contains=@vim9Continue,@vimType transparent
605606
syn region vimCompoundType contained matchgroup=vimType start="\<\%(list\|dict\)<" end=">" contains=@vimType oneline transparent
606607
syn match vimUserType contained "\<\%(\h\w*\.\)*\u\w*\>"
607608

608-
syn cluster vimType contains=vimType,vimCompoundType,vimUserType
609+
syn cluster vimType contains=vimType,vimTypeAny,vimCompoundType,vimUserType
609610

610611
" Classes, Enums And Interfaces: {{{2
611612
" =============================
@@ -1119,7 +1120,8 @@ syn match vim9Variable contained "\<\h\w*\>" skipwhite nextgroup=vim9VariableTyp
11191120
syn region vim9VariableList contained start="\[" end="]" contains=@vimContinue,@vimSpecialVar,vim9Variable skipwhite nextgroup=vimLetHeredoc
11201121

11211122
syn match vim9VariableTypeSep contained "\S\@1<=:\%(\s\|\n\)\@=" skipwhite nextgroup=@vim9VariableType
1122-
syn keyword vim9VariableType contained any blob bool channel float job number string void skipwhite nextgroup=vimLetHeredoc
1123+
syn keyword vim9VariableType contained blob bool channel float job number string void skipwhite nextgroup=vimLetHeredoc
1124+
syn keyword vim9VariableTypeAny contained any skipwhite nextgroup=vimLetHeredoc
11231125
syn match vim9VariableType contained "\<\%(func\)\>" skipwhite nextgroup=vimLetHeredoc
11241126
syn region vim9VariableCompoundType contained
11251127
\ matchgroup=vim9VariableType
@@ -1145,7 +1147,7 @@ syn region vim9VariableCompoundType contained
11451147
\ transparent
11461148
syn match vim9VariableUserType contained "\<\%(\h\w*\.\)*\u\w*\>" skipwhite nextgroup=vimLetHeredoc
11471149

1148-
syn cluster vim9VariableType contains=vim9VariableType,vim9VariableCompoundType,vim9VariableUserType
1150+
syn cluster vim9VariableType contains=vim9VariableType,vim9VariableTypeAny,vim9VariableCompoundType,vim9VariableUserType
11491151

11501152
" Lockvar and Unlockvar: {{{2
11511153
" =====================
@@ -2486,6 +2488,7 @@ if !exists("skip_vim_syntax_inits")
24862488
hi def link vimThrow vimCommand
24872489
hi def link vimTodo Todo
24882490
hi def link vimType Type
2491+
hi def link vimTypeAny vimType
24892492
hi def link vimUniq vimCommand
24902493
hi def link vimUniqBang vimBang
24912494
hi def link vimUniqOptions Special
@@ -2576,6 +2579,7 @@ if !exists("skip_vim_syntax_inits")
25762579
hi def link vim9TypeEquals vimOper
25772580
hi def link vim9Variable vimVar
25782581
hi def link vim9VariableType vimType
2582+
hi def link vim9VariableTypeAny vimType
25792583
hi def link vim9Var vimCommand
25802584
hi def link vim9Vim9ScriptArg Special
25812585
hi def link vim9Vim9Script vimCommand

0 commit comments

Comments
 (0)