Skip to content

Commit 4de931d

Browse files
dkearnszzzyxwvut
authored andcommitted
runtime(vim): Update base syntax, match enum constructor type args
closes: #17840 Co-authored-by: Aliaksei Budavei <[email protected]> Signed-off-by: Doug Kearns <[email protected]> Signed-off-by: Christian Brabandt <[email protected]>
1 parent 72473ce commit 4de931d

File tree

6 files changed

+114
-4
lines changed

6 files changed

+114
-4
lines changed

runtime/syntax/generator/vim.vim.base

Lines changed: 9 additions & 2 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 Jul 23
5+
" Last Change: 2025 Jul 24
66
" Former Maintainer: Charles E. Campbell
77

88
" DO NOT CHANGE DIRECTLY.
@@ -698,12 +698,19 @@ if s:vim9script
698698
syn cluster vim9EnumNameContinue contains=vim9EnumNameContinue,vim9EnumNameContinueComment
699699

700700
" enforce enum value list location
701-
syn match vim9EnumValue contained "\<\a\w*\>" nextgroup=vim9EnumValueArgList,vim9EnumValueListComma,vim9Comment
701+
syn match vim9EnumValue contained "\<\a\w*\>" nextgroup=vim9EnumValueTypeArgs,vim9EnumValueArgList,vim9EnumValueListComma,vim9Comment
702702
syn match vim9EnumValueListComma contained "," skipwhite skipempty nextgroup=vim9EnumValue,vim9EnumValueListCommaComment
703703
syn region vim9EnumValueListCommaComment contained
704704
\ start="#" skip="\n\s*\%(\\\|#\\ \)" end="$"
705705
\ skipwhite skipempty nextgroup=vim9EnumValueListCommaComment,vim9EnumValue
706706
\ contains=@vimCommentGroup,vimCommentString
707+
syn region vim9EnumValueTypeArgs contained
708+
\ matchgroup=Delimiter
709+
\ start="<\ze\a"
710+
\ end=">"
711+
\ nextgroup=vim9EnumValueArgList
712+
\ contains=@vimType
713+
\ oneline
707714
syn region vim9EnumValueArgList contained
708715
\ matchgroup=vimParenSep start="(" end=")"
709716
\ nextgroup=vim9EnumValueListComma
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
| +0#0000e05#a8a8a8255@1>v+0#af5f00255#ffffff0|i|m|9|s|c|r|i|p|t| +0#0000000&@62
2+
| +0#0000e05#a8a8a8255@1|#+0&#ffffff0| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |h|i|g|h|l|i|g|h|t| |l|i|n|k| |v|i|m|9|D|e|f|T|y|p|e|P|a|r|a|m| |T|o|d|o| +0#0000000&@19
3+
| +0#0000e05#a8a8a8255@1|#+0&#ffffff0| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |h|i|g|h|l|i|g|h|t| |l|i|n|k| |v|i|m|9|E|n|u|m|V|a|l|u|e| |I|d|e|n|t|i|f|i|e|r| +0#0000000&@16
4+
| +0#0000e05#a8a8a8255@1|#+0&#ffffff0| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |l|e|t| |g|:|v|i|m|s|y|n|_|f|o|l|d|i|n|g| |=| |"+0#e000002&|e|f|"| +0#0000000&@28
5+
| +0#0000e05#a8a8a8255@1|#+0&#ffffff0| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |s|e|t|l| |f|d|c|=|2| |f|d|l|=|9@1| |f|d|m|=|s|y|n|t|a|x| +0#0000000&@27
6+
| +0#0000e05#a8a8a8255@1|#+0&#ffffff0| +0#0000000&|S+0#e000e06&|e@1|:| +0#0000e05&|h|t@1|p|s|:|/@1|g|i|t|h|u|b|.|c|o|m|/|v|i|m|/|v|i|m|/|p|u|l@1|/|1|7|3|1|3|#|i|s@1|u|e|c|o|m@1|e|n|t|-|3|0|3@1|5|3|7|1|2|7| |(|A|l|i
7+
| +0&#a8a8a8255@1|a+0&#ffffff0|k|s|e|i| |B|u|d|a|v|e|i|)| +0#0000000&@58
8+
| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72
9+
| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72
10+
|-+0#0000e05#a8a8a8255| |e+0#af5f00255#ffffff0|n|u|m| +0#0000000&|C|o|m@1|o|n|P|a|i|r| @57
11+
||+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@3|H+0#00e0e07&|e|l@1|o|W|o|r|l|d|<+0#e000e06&|s+0#00e0003&|t|r|i|n|g|,+0#0000000&| |s+0#00e0003&|t|r|i|n|g|>+0#e000e06&|(|'+0#e000002&|h|e|l@1|o|'|,+0#0000000&| |'+0#e000002&|w|o|r|l|d|'|)+0#e000e06&|,+0#0000000&| @23
12+
||+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@3|B+0#00e0e07&|o@1|l|e|a|n|s|<+0#e000e06&|b+0#00e0003&|o@1|l|,+0#0000000&| |b+0#00e0003&|o@1|l|>+0#e000e06&|(|t+0#e000002&|r|u|e|,+0#0000000&| |f+0#e000002&|a|l|s|e|)+0#e000e06&| +0#0000000&@35
13+
||+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@72
14+
||+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@3|c+0#af5f00255&|o|n|s|t| +0#0000000&|_|f|s|t|:| |a+0#00e0003&|n|y| +0#0000000&@53
15+
||+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@3|c+0#af5f00255&|o|n|s|t| +0#0000000&|_|s|n|d|:| |a+0#00e0003&|n|y| +0#0000000&@53
16+
||+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@72
17+
|-+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@3|d+0#af5f00255&|e|f| +0#0000000&|n+0#00e0e07&|e|w|<+0#e000e06&|T+0#0000001#ffff4012|,+0#0000000#ffffff0| |U+0#0000001#ffff4012|>+0#e000e06#ffffff0|(|f+0#0000000&|s|t|:| |T|,| |s|n|d|:| |U|)+0#e000e06&| +0#0000000&@39
18+
|2+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@7|t+0#00e0e07&|h|i|s|.+0#af5f00255&|_+0#0000000&|f|s|t| |=+0#af5f00255&| +0#0000000&|f|s|t| @49
19+
|2+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@7|t+0#00e0e07&|h|i|s|.+0#af5f00255&|_+0#0000000&|s|n|d| |=+0#af5f00255&| +0#0000000&|s|n|d| @49
20+
@57|1|,|1| @10|T|o|p|
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
||+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@3|c+0#af5f00255&|o|n|s|t| +0#0000000&|_|f|s|t|:| |a+0#00e0003&|n|y| +0#0000000&@53
2+
||+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@3|c+0#af5f00255&|o|n|s|t| +0#0000000&|_|s|n|d|:| |a+0#00e0003&|n|y| +0#0000000&@53
3+
||+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@72
4+
|-+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@3|d+0#af5f00255&|e|f| +0#0000000&|n+0#00e0e07&|e|w|<+0#e000e06&|T+0#0000001#ffff4012|,+0#0000000#ffffff0| |U+0#0000001#ffff4012|>+0#e000e06#ffffff0|(|f+0#0000000&|s|t|:| |T|,| |s|n|d|:| |U|)+0#e000e06&| +0#0000000&@39
5+
|2+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@7|t+0#00e0e07&|h|i|s|.+0#af5f00255&|_+0#0000000&|f|s|t| |=+0#af5f00255&| +0#0000000&|f|s|t| @49
6+
|2+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@7>t+0#00e0e07&|h|i|s|.+0#af5f00255&|_+0#0000000&|s|n|d| |=+0#af5f00255&| +0#0000000&|s|n|d| @49
7+
|2+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@3|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@62
8+
||+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@72
9+
|-+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@3|d+0#af5f00255&|e|f| +0#0000000&|F|i|r|s|t|<+0#e000e06&|T+0#0000001#ffff4012|>+0#e000e06#ffffff0|(|)|:+0#0000000&| |T| @51
10+
|2+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@7|r+0#af5f00255&|e|t|u|r|n| +0#0000000&|t+0#00e0e07&|h|i|s|.+0#af5f00255&|_+0#0000000&|f|s|t| @48
11+
|2+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@3|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@62
12+
||+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@72
13+
|-+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@3|d+0#af5f00255&|e|f| +0#0000000&|S|e|c|o|n|d|<+0#e000e06&|T+0#0000001#ffff4012|>+0#e000e06#ffffff0|(|)|:+0#0000000&| |T| @50
14+
|2+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@7|r+0#af5f00255&|e|t|u|r|n| +0#0000000&|t+0#00e0e07&|h|i|s|.+0#af5f00255&|_+0#0000000&|s|n|d| @48
15+
|2+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@3|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@62
16+
||+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@72
17+
|-+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@3|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&@48
18+
|2+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@7|r+0#af5f00255&|e|t|u|r|n| +0#0000000&|p+0#00e0e07&|r|i|n|t|f|(+0#e000e06&|"+0#e000002&|(|%|s|,| |%|s|)|"|,+0#0000000&| |t+0#00e0e07&|h|i|s|.+0#af5f00255&|_+0#0000000&|f|s|t|,| |t+0#00e0e07&|h|i|s|.+0#af5f00255&|_+0#0000000&|s|n|d|)+0#e000e06&| +0#0000000&@17
19+
|2+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@3|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@62
20+
@57|1|8|,|9| @9|7|0|%|
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
|2+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@3|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@62
2+
||+0#0000e05#a8a8a8255| |e+0#af5f00255#ffffff0|n|d|e|n|u|m| +0#0000000&@65
3+
| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72
4+
| +0#0000e05#a8a8a8255@1|e+0#af5f00255#ffffff0|c|h|o| +0#0000000&|C|o|m@1|o|n|P|a|i|r|.+0#af5f00255&|H+0#0000000&|e|l@1|o|W|o|r|l|d| @46
5+
| +0#0000e05#a8a8a8255@1|e+0#af5f00255#ffffff0|c|h|o| +0#0000000&|C|o|m@1|o|n|P|a|i|r|.+0#af5f00255&|B+0#0000000&|o@1|l|e|a|n|s| @48
6+
| +0#0000e05#a8a8a8255@1> +0#0000000#ffffff0@72
7+
|~+0#4040ff13&| @73
8+
|~| @73
9+
|~| @73
10+
|~| @73
11+
|~| @73
12+
|~| @73
13+
|~| @73
14+
|~| @73
15+
|~| @73
16+
|~| @73
17+
|~| @73
18+
|~| @73
19+
|~| @73
20+
| +0#0000000&@56|3|6|,|0|-|1| @7|B|o|t|
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
vim9script
2+
# VIM_TEST_SETUP highlight link vim9DefTypeParam Todo
3+
# VIM_TEST_SETUP highlight link vim9EnumValue Identifier
4+
# VIM_TEST_SETUP let g:vimsyn_folding = "ef"
5+
# VIM_TEST_SETUP setl fdc=2 fdl=99 fdm=syntax
6+
# See: https://github.com/vim/vim/pull/17313#issuecomment-3033537127 (Aliaksei Budavei)
7+
8+
9+
enum CommonPair
10+
HelloWorld<string, string>('hello', 'world'),
11+
Booleans<bool, bool>(true, false)
12+
13+
const _fst: any
14+
const _snd: any
15+
16+
def new<T, U>(fst: T, snd: U)
17+
this._fst = fst
18+
this._snd = snd
19+
enddef
20+
21+
def First<T>(): T
22+
return this._fst
23+
enddef
24+
25+
def Second<T>(): T
26+
return this._snd
27+
enddef
28+
29+
def string(): string
30+
return printf("(%s, %s)", this._fst, this._snd)
31+
enddef
32+
endenum
33+
34+
echo CommonPair.HelloWorld
35+
echo CommonPair.Booleans
36+

runtime/syntax/vim.vim

Lines changed: 9 additions & 2 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 Jul 23
5+
" Last Change: 2025 Jul 24
66
" Former Maintainer: Charles E. Campbell
77

88
" DO NOT CHANGE DIRECTLY.
@@ -752,12 +752,19 @@ if s:vim9script
752752
syn cluster vim9EnumNameContinue contains=vim9EnumNameContinue,vim9EnumNameContinueComment
753753

754754
" enforce enum value list location
755-
syn match vim9EnumValue contained "\<\a\w*\>" nextgroup=vim9EnumValueArgList,vim9EnumValueListComma,vim9Comment
755+
syn match vim9EnumValue contained "\<\a\w*\>" nextgroup=vim9EnumValueTypeArgs,vim9EnumValueArgList,vim9EnumValueListComma,vim9Comment
756756
syn match vim9EnumValueListComma contained "," skipwhite skipempty nextgroup=vim9EnumValue,vim9EnumValueListCommaComment
757757
syn region vim9EnumValueListCommaComment contained
758758
\ start="#" skip="\n\s*\%(\\\|#\\ \)" end="$"
759759
\ skipwhite skipempty nextgroup=vim9EnumValueListCommaComment,vim9EnumValue
760760
\ contains=@vimCommentGroup,vimCommentString
761+
syn region vim9EnumValueTypeArgs contained
762+
\ matchgroup=Delimiter
763+
\ start="<\ze\a"
764+
\ end=">"
765+
\ nextgroup=vim9EnumValueArgList
766+
\ contains=@vimType
767+
\ oneline
761768
syn region vim9EnumValueArgList contained
762769
\ matchgroup=vimParenSep start="(" end=")"
763770
\ nextgroup=vim9EnumValueListComma

0 commit comments

Comments
 (0)