Skip to content

Commit fe24972

Browse files
dkearnschrisbra
authored andcommitted
runtime(vim): Update base syntax, refine object constructor matching
Match "object" and "<" ... ">" separately with dedicated syntax groups to allow for highlighting distinct from that generally used for types. closes: #18721 Signed-off-by: Doug Kearns <[email protected]> Signed-off-by: Christian Brabandt <[email protected]>
1 parent 54cc820 commit fe24972

8 files changed

Lines changed: 48 additions & 42 deletions

runtime/syntax/generator/vim.vim.base

Lines changed: 11 additions & 7 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: 2025 Nov 10
5+
" Last Change: 2025 Nov 11
66
" Former Maintainer: Charles E. Campbell
77

88
" DO NOT CHANGE DIRECTLY.
@@ -585,9 +585,10 @@ syn match vimParamType contained ":\s" skipwhite skipnl nextgroup=@vimType conta
585585
syn match vimTypeSep contained ":\%(\s\|\n\)\@=" skipwhite nextgroup=@vimType
586586
syn keyword vimType contained blob bool channel float job number string void
587587
syn keyword vimTypeAny contained any
588-
syn region vimTypeObject contained
589-
\ matchgroup=vimType
590-
\ start="\<object<"
588+
syn match vimTypeObject contained "\<object<\@=" nextgroup=vimTypeObjectArgs
589+
syn region vimTypeObjectArgs contained
590+
\ matchgroup=vimTypeObjectBracket
591+
\ start="<"
591592
\ end=">"
592593
\ contains=vimTypeAny,vimTypeObject,vimUserType
593594
\ oneline
@@ -1147,9 +1148,10 @@ syn region vim9VariableList contained start="\[" end="]" contains=@vimContinue,@
11471148
syn match vim9VariableTypeSep contained "\S\@1<=:\%(\s\|\n\)\@=" skipwhite nextgroup=@vim9VariableType
11481149
syn keyword vim9VariableType contained blob bool channel float job number string void skipwhite nextgroup=vimLetHeredoc
11491150
syn keyword vim9VariableTypeAny contained any skipwhite nextgroup=vimLetHeredoc
1150-
syn region vim9VariableTypeObject contained
1151-
\ matchgroup=vimType
1152-
\ start="\<object<"
1151+
syn match vim9VariableTypeObject contained "\<object<\@=" nextgroup=vim9VariableTypeObjectArgs
1152+
syn region vim9VariableTypeObjectArgs
1153+
\ matchgroup=vim9VariableTypeObjectBracket
1154+
\ start="<"
11531155
\ end=">"
11541156
\ contains=vimTypeAny,vimTypeObject,vimUserType
11551157
\ oneline
@@ -2613,6 +2615,7 @@ if !exists("skip_vim_syntax_inits")
26132615
hi def link vimType Type
26142616
hi def link vimTypeAny vimType
26152617
hi def link vimTypeObject vimType
2618+
hi def link vimTypeObjectBracket vimTypeObject
26162619
hi def link vimUniq vimCommand
26172620
hi def link vimUniqBang vimBang
26182621
hi def link vimUniqOptions Special
@@ -2706,6 +2709,7 @@ if !exists("skip_vim_syntax_inits")
27062709
hi def link vim9VariableType vimType
27072710
hi def link vim9VariableTypeAny vimTypeAny
27082711
hi def link vim9VariableTypeObject vimTypeObject
2712+
hi def link vim9VariableTypeObjectBracket vimTypeObjectBracket
27092713
hi def link vim9Var vimCommand
27102714
hi def link vim9Vim9ScriptArg Special
27112715
hi def link vim9Vim9Script vimCommand

runtime/syntax/testdir/dumps/vim9_types_example_object_00.dump

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
>v+0#af5f00255#ffffff0|i|m|9|s|c|r|i|p|t| +0#0000000&@64
22
|#+0#0000e05&| |V|i|m|9| |o|b|j|e|c|t| |t|y|p|e| |c|o|n|s|t|r|u|c|t|o|r| +0#0000000&@44
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|O|b|j|e|c|t| |T|o|d|o| +0#0000000&@31
4-
|#+0#0000e05&| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |h|i| |l|i|n|k| |v|i|m|9|V|a|r|i|a|b|l|e|T|y|p|e|O|b|j|e|c|t| |T|o|d|o| +0#0000000&@22
53
@75
64
@75
75
|#+0#0000e05&| |I|s@1|u|e| |#|1|8|6|7@1| |(|N|o| |r|e|c|o|g|n|i|t|i|o|n| |o|f| |o|b|j|e|c|t|<|a|n|y|>| |t|y|p|e|s| |-| |A|l|i|a|k|s|e|i| |B|u|d|a|v|e|i|)| +0#0000000&@3
@@ -17,4 +15,6 @@
1715
|e+0#af5f00255&|n|d|c|l|a|s@1| +0#0000000&@66
1816
@75
1917
|e+0#af5f00255&|n|u|m| +0#0000000&|E| |i+0#af5f00255&|m|p|l|e|m|e|n|t|s| +0#0000000&|I| @55
18+
@2|I|N|S|T|A|N|C|E| @64
19+
@75
2020
@57|1|,|1| @10|T|o|p|
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
| +0&#ffffff0@1|d+0#af5f00255&|e|f| +0#0000000&|s+0#00e0e07&|t|r|i|n|g|(+0#e000e06&|)|:+0#0000000&| |s+0#00e0003&|t|r|i|n|g| +0#0000000&@52
2-
@4|r+0#af5f00255&|e|t|u|r|n| +0#0000000&|"+0#e000002&|C|"| +0#0000000&@60
3-
@2|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@66
1+
| +0&#ffffff0@1|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@66
42
|e+0#af5f00255&|n|d|c|l|a|s@1| +0#0000000&@66
53
@75
6-
>e+0#af5f00255&|n|u|m| +0#0000000&|E| |i+0#af5f00255&|m|p|l|e|m|e|n|t|s| +0#0000000&|I| @55
4+
|e+0#af5f00255&|n|u|m| +0#0000000&|E| |i+0#af5f00255&|m|p|l|e|m|e|n|t|s| +0#0000000&|I| @55
75
@2|I|N|S|T|A|N|C|E| @64
8-
@75
6+
> @74
97
@2|d+0#af5f00255&|e|f| +0#0000000&|s+0#00e0e07&|t|r|i|n|g|(+0#e000e06&|)|:+0#0000000&| |s+0#00e0003&|t|r|i|n|g| +0#0000000&@52
108
@4|r+0#af5f00255&|e|t|u|r|n| +0#0000000&|"+0#e000002&|E|"| +0#0000000&@60
119
@2|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@66
@@ -17,4 +15,6 @@
1715
|e+0#af5f00255&|c|h|o| +0#0000000&|(+0#e000e06&|c+0#0000000&|,| |e|)+0#e000e06&| +0#0000000&|=+0#af5f00255&@1| +0#0000000&|o|s| @57
1816
@75
1917
|~+0#4040ff13&| @73
20-
| +0#0000000&@56|1|9|,|1| @9|B|o|t|
18+
|~| @73
19+
|~| @73
20+
| +0#0000000&@56|1|9|,|0|-|1| @7|B|o|t|
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
>v+0#af5f00255#ffffff0|i|m|9|s|c|r|i|p|t| +0#0000000&@64
22
|#+0#0000e05&| |V|i|m|9| |o|b|j|e|c|t| |t|y|p|e| |c|o|n|s|t|r|u|c|t|o|r| +0#0000000&@44
3-
|#+0#0000e05&| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |h|i| |l|i|n|k| |v|i|m|I|y|p|e|O|b|j|e|c|t| |T|o|d|o| +0#0000000&@31
4-
|#+0#0000e05&| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |h|i| |l|i|n|k| |v|i|m|9|V|a|r|i|a|b|l|e|I|y|p|e|O|b|j|e|c|t| |T|o|d|o| +0#0000000&@22
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|O|b|j|e|c|t| |T|o|d|o| +0#0000000&@31
4+
|#+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|O|b|j|e|c|t|B|r|a|c|k|e|t| |T|i|t|l|e| +0#0000000&@23
55
@75
66
@75
77
|i+0#af5f00255&|n|t|e|r|f|a|c|e| +0#0000000&|I| @63
88
|e+0#af5f00255&|n|d|i|n|t|e|r|f|a|c|e| +0#0000000&@62
99
@75
10-
|v+0#af5f00255&|a|r| +0#0000000&|a|:| |o+0#00e0003&|b|j|e|c|t|<|I+0#0000000&|>+0#00e0003&| +0#0000000&@58
11-
|v+0#af5f00255&|a|r| +0#0000000&|b|:| |o+0#00e0003&|b|j|e|c|t|<|a|n|y|>| +0#0000000&@56
12-
|v+0#af5f00255&|a|r| +0#0000000&|c|:| |o+0#00e0003&|b|j|e|c|t|<|o|b|j|e|c|t|<|I+0#0000000&|>+0#00e0003&@1| +0#0000000&@50
13-
|v+0#af5f00255&|a|r| +0#0000000&|d|:| |o+0#00e0003&|b|j|e|c|t|<|o|b|j|e|c|t|<|a|n|y|>@1| +0#0000000&@48
10+
|v+0#af5f00255&|a|r| +0#0000000&|a|:| |o+0#0000001#ffff4012|b|j|e|c|t|<+0#e000e06#ffffff0|I+0#0000000&|>+0#e000e06&| +0#0000000&@58
11+
|v+0#af5f00255&|a|r| +0#0000000&|b|:| |o+0#0000001#ffff4012|b|j|e|c|t|<+0#e000e06#ffffff0|a+0#00e0003&|n|y|>+0#e000e06&| +0#0000000&@56
12+
|v+0#af5f00255&|a|r| +0#0000000&|c|:| |o+0#0000001#ffff4012|b|j|e|c|t|<+0#e000e06#ffffff0|o+0#0000001#ffff4012|b|j|e|c|t|<+0#e000e06#ffffff0|I+0#0000000&|>+0#e000e06&@1| +0#0000000&@50
13+
|v+0#af5f00255&|a|r| +0#0000000&|d|:| |o+0#0000001#ffff4012|b|j|e|c|t|<+0#e000e06#ffffff0|o+0#0000001#ffff4012|b|j|e|c|t|<+0#e000e06#ffffff0|a+0#00e0003&|n|y|>+0#e000e06&@1| +0#0000000&@48
1414
@75
1515
|d+0#af5f00255&|e|f| +0#0000000&|F|o@1|(+0#e000e06&| +0#0000000&@66
16-
@4|a|r|g|1|:| |o+0#00e0003&|b|j|e|c|t|<|I+0#0000000&|>+0#00e0003&|,+0#0000000&| @54
17-
@4|a|r|g|2|:| |o+0#00e0003&|b|j|e|c|t|<|a|n|y|>|,+0#0000000&| @52
18-
@4|a|r|g|3|:| |o+0#00e0003&|b|j|e|c|t|<|o|b|j|e|c|t|<|I+0#0000000&|>+0#00e0003&@1|,+0#0000000&| @46
19-
@4|a|r|g|4|:| |o+0#00e0003&|b|j|e|c|t|<|o|b|j|e|c|t|<|a|n|y|>@1|)+0#e000e06&| +0#0000000&@44
16+
@4|a|r|g|1|:| |o+0#0000001#ffff4012|b|j|e|c|t|<+0#e000e06#ffffff0|I+0#0000000&|>+0#e000e06&|,+0#0000000&| @54
17+
@4|a|r|g|2|:| |o+0#0000001#ffff4012|b|j|e|c|t|<+0#e000e06#ffffff0|a+0#00e0003&|n|y|>+0#e000e06&|,+0#0000000&| @52
18+
@4|a|r|g|3|:| |o+0#0000001#ffff4012|b|j|e|c|t|<+0#e000e06#ffffff0|o+0#0000001#ffff4012|b|j|e|c|t|<+0#e000e06#ffffff0|I+0#0000000&|>+0#e000e06&@1|,+0#0000000&| @46
19+
@4|a|r|g|4|:| |o+0#0000001#ffff4012|b|j|e|c|t|<+0#e000e06#ffffff0|o+0#0000001#ffff4012|b|j|e|c|t|<+0#e000e06#ffffff0|a+0#00e0003&|n|y|>+0#e000e06&@1|)| +0#0000000&@44
2020
@57|1|,|1| @10|T|o|p|

runtime/syntax/testdir/dumps/vim9_types_object_01.dump

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
| +0&#ffffff0@74
22
|d+0#af5f00255&|e|f| +0#0000000&|F|o@1|(+0#e000e06&| +0#0000000&@66
3-
@4|a|r|g|1|:| |o+0#00e0003&|b|j|e|c|t|<|I+0#0000000&|>+0#00e0003&|,+0#0000000&| @54
4-
@4|a|r|g|2|:| |o+0#00e0003&|b|j|e|c|t|<|a|n|y|>|,+0#0000000&| @52
5-
@4|a|r|g|3|:| |o+0#00e0003&|b|j|e|c|t|<|o|b|j|e|c|t|<|I+0#0000000&|>+0#00e0003&@1|,+0#0000000&| @46
6-
@4>a|r|g|4|:| |o+0#00e0003&|b|j|e|c|t|<|o|b|j|e|c|t|<|a|n|y|>@1|)+0#e000e06&| +0#0000000&@44
3+
@4|a|r|g|1|:| |o+0#0000001#ffff4012|b|j|e|c|t|<+0#e000e06#ffffff0|I+0#0000000&|>+0#e000e06&|,+0#0000000&| @54
4+
@4|a|r|g|2|:| |o+0#0000001#ffff4012|b|j|e|c|t|<+0#e000e06#ffffff0|a+0#00e0003&|n|y|>+0#e000e06&|,+0#0000000&| @52
5+
@4|a|r|g|3|:| |o+0#0000001#ffff4012|b|j|e|c|t|<+0#e000e06#ffffff0|o+0#0000001#ffff4012|b|j|e|c|t|<+0#e000e06#ffffff0|I+0#0000000&|>+0#e000e06&@1|,+0#0000000&| @46
6+
@4>a|r|g|4|:| |o+0#0000001#ffff4012|b|j|e|c|t|<+0#e000e06#ffffff0|o+0#0000001#ffff4012|b|j|e|c|t|<+0#e000e06#ffffff0|a+0#00e0003&|n|y|>+0#e000e06&@1|)| +0#0000000&@44
77
|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@68
88
@75
9-
|d+0#af5f00255&|e|f| +0#0000000&|B|a|r|(+0#e000e06&|)|:+0#0000000&| |o+0#00e0003&|b|j|e|c|t|<|I+0#0000000&|>+0#00e0003&| +0#0000000&@54
9+
|d+0#af5f00255&|e|f| +0#0000000&|B|a|r|(+0#e000e06&|)|:+0#0000000&| |o+0#0000001#ffff4012|b|j|e|c|t|<+0#e000e06#ffffff0|I+0#0000000&|>+0#e000e06&| +0#0000000&@54
1010
|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@68
1111
@75
12-
|d+0#af5f00255&|e|f| +0#0000000&|B|a|z|(+0#e000e06&|)|:+0#0000000&| |o+0#00e0003&|b|j|e|c|t|<|o|b|j|e|c|t|<|I+0#0000000&|>+0#00e0003&@1| +0#0000000&@46
12+
|d+0#af5f00255&|e|f| +0#0000000&|B|a|z|(+0#e000e06&|)|:+0#0000000&| |o+0#0000001#ffff4012|b|j|e|c|t|<+0#e000e06#ffffff0|o+0#0000001#ffff4012|b|j|e|c|t|<+0#e000e06#ffffff0|I+0#0000000&|>+0#e000e06&@1| +0#0000000&@46
1313
|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@68
1414
@75
1515
|~+0#4040ff13&| @73

runtime/syntax/testdir/input/vim9_types_example_object.vim

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
vim9script
22
# Vim9 object type constructor
3-
# VIM_TEST_SETUP hi link vimTypeObject Todo
4-
# VIM_TEST_SETUP hi link vim9VariableTypeObject Todo
53

64

75
# Issue #18677 (No recognition of object<any> types - Aliaksei Budavei)

runtime/syntax/testdir/input/vim9_types_object.vim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
vim9script
22
# Vim9 object type constructor
3-
# VIM_TEST_SETUP hi link vimIypeObject Todo
4-
# VIM_TEST_SETUP hi link vim9VariableIypeObject Todo
3+
# VIM_TEST_SETUP hi link vimTypeObject Todo
4+
# VIM_TEST_SETUP hi link vimTypeObjectBracket Title
55

66

77
interface I

runtime/syntax/vim.vim

Lines changed: 11 additions & 7 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: 2025 Nov 10
5+
" Last Change: 2025 Nov 11
66
" Former Maintainer: Charles E. Campbell
77

88
" DO NOT CHANGE DIRECTLY.
@@ -639,9 +639,10 @@ syn match vimParamType contained ":\s" skipwhite skipnl nextgroup=@vimType conta
639639
syn match vimTypeSep contained ":\%(\s\|\n\)\@=" skipwhite nextgroup=@vimType
640640
syn keyword vimType contained blob bool channel float job number string void
641641
syn keyword vimTypeAny contained any
642-
syn region vimTypeObject contained
643-
\ matchgroup=vimType
644-
\ start="\<object<"
642+
syn match vimTypeObject contained "\<object<\@=" nextgroup=vimTypeObjectArgs
643+
syn region vimTypeObjectArgs contained
644+
\ matchgroup=vimTypeObjectBracket
645+
\ start="<"
645646
\ end=">"
646647
\ contains=vimTypeAny,vimTypeObject,vimUserType
647648
\ oneline
@@ -1203,9 +1204,10 @@ syn region vim9VariableList contained start="\[" end="]" contains=@vimContinue,@
12031204
syn match vim9VariableTypeSep contained "\S\@1<=:\%(\s\|\n\)\@=" skipwhite nextgroup=@vim9VariableType
12041205
syn keyword vim9VariableType contained blob bool channel float job number string void skipwhite nextgroup=vimLetHeredoc
12051206
syn keyword vim9VariableTypeAny contained any skipwhite nextgroup=vimLetHeredoc
1206-
syn region vim9VariableTypeObject contained
1207-
\ matchgroup=vimType
1208-
\ start="\<object<"
1207+
syn match vim9VariableTypeObject contained "\<object<\@=" nextgroup=vim9VariableTypeObjectArgs
1208+
syn region vim9VariableTypeObjectArgs
1209+
\ matchgroup=vim9VariableTypeObjectBracket
1210+
\ start="<"
12091211
\ end=">"
12101212
\ contains=vimTypeAny,vimTypeObject,vimUserType
12111213
\ oneline
@@ -2675,6 +2677,7 @@ if !exists("skip_vim_syntax_inits")
26752677
hi def link vimType Type
26762678
hi def link vimTypeAny vimType
26772679
hi def link vimTypeObject vimType
2680+
hi def link vimTypeObjectBracket vimTypeObject
26782681
hi def link vimUniq vimCommand
26792682
hi def link vimUniqBang vimBang
26802683
hi def link vimUniqOptions Special
@@ -2768,6 +2771,7 @@ if !exists("skip_vim_syntax_inits")
27682771
hi def link vim9VariableType vimType
27692772
hi def link vim9VariableTypeAny vimTypeAny
27702773
hi def link vim9VariableTypeObject vimTypeObject
2774+
hi def link vim9VariableTypeObjectBracket vimTypeObjectBracket
27712775
hi def link vim9Var vimCommand
27722776
hi def link vim9Vim9ScriptArg Special
27732777
hi def link vim9Vim9Script vimCommand

0 commit comments

Comments
 (0)