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 18
5+ " Last Change: 2025 Jul 23
66" Former Maintainer: Charles E. Campbell
77
88" DO NOT CHANGE DIRECTLY.
@@ -267,6 +267,8 @@ syn match vimVimVar "\<v:" nextgroup=vimSubscript,vimVimVarName,vimVarNameError
267267syn match vimOptionVar " &\% ([lg]:\)\= " nextgroup =vimSubscript,vimOptionVarName,vimVarNameError
268268syn cluster vimSpecialVar contains =vimEnvvar,vimLetRegister,vimOptionVar,vimVimVar
269269
270+ Vim9 syn match vimVar contained " \<\h\w *\z e<" nextgroup= vim9TypeArgs
271+
270272Vim9 syn match vim9LhsVariable " \s\=\h [a-zA-Z0-9#_]*\z e\s\+ [-+/*%]\= ="
271273Vim9 syn match vim9LhsVariable " \s\=\h [a-zA-Z0-9#_]*\z e\s\+\.\. ="
272274Vim9 syn match vim9LhsVariable " \s\=\% ([bwgt]:\)\=\h [a-zA-Z0-9#_]*\z e\s\+ =<<" skipwhite nextgroup= vimLetHeredoc contains= vimVarScope
@@ -468,7 +470,7 @@ syn match vimFunctionName contained
468470 \ contains= vimFunctionError,vimFunctionScope,vimFunctionSID,Tag
469471syn match vimDefName contained
470472 \ " \% (<[sS][iI][dD]>\| [bwglstav]:\)\=\% ([[:alnum:]_#.]\+\| {.\{ -1,}}\)\+ "
471- \ nextgroup= vimDefParams,vimCmdSep,vimComment,vim9Comment
473+ \ nextgroup= vimDefTypeParams, vimDefParams,vimCmdSep,vimComment,vim9Comment
472474 \ contains= vimFunctionError,vimFunctionScope,vimFunctionSID,Tag
473475
474476syn match vimFunction " \< fu\% [nction]\> " skipwhite nextgroup =vimFunctionBang,vimFunctionName,vimFunctionPattern,vimCmdSep,vimComment
@@ -498,8 +500,15 @@ syn region vimDefParams contained
498500 \ end = " )"
499501 \ skipwhite skipempty nextgroup= vimDefBody,vimDefComment,vimEnddef,vimReturnType,vimCommentError
500502 \ contains= vimDefParam,vim9Comment,vimFunctionParamEquals,vimOperParen
503+ syn region vimDefTypeParams contained
504+ \ matchgroup= Delimiter
505+ \ start = " <"
506+ \ end = " >"
507+ \ nextgroup= vimDefParams
508+ \ contains= vim9DefTypeParam
501509syn match vimFunctionParam contained " \<\h\w *\>\|\.\.\. " skipwhite nextgroup =vimFunctionParamEquals
502510syn match vimDefParam contained " \<\h\w *\> " skipwhite nextgroup =vimParamType,vimFunctionParamEquals
511+ syn match vim9DefTypeParam contained " \<\u\w *\> "
503512
504513syn match vimFunctionParamEquals contained " =" skipwhite nextgroup =@vimExprList
505514syn match vimFunctionMod contained " \<\% (abort\| closure\| dict\| range\)\> " skipwhite skipempty nextgroup =vimFunctionBody,vimFunctionComment,vimEndfunction,vimFunctionMod,vim9CommentError
@@ -531,7 +540,7 @@ if exists("g:vimsyn_folding") && g:vimsyn_folding =~# 'f'
531540 syn region vimDefFold
532541 \ start = " \< def!"
533542 " \ assume no dict literal in curly-brace name expressions
534- \ start = " \<def\>\s*\%([[:alnum:]_:<> .#]\+\| {.\{ -1,}}\)\+ ( "
543+ \ start = " \<def\>\s*\%([[:alnum:]_:<> .#]\+\| {.\{ -1,}}\)\+ [<(] "
535544 \ end = " ^\s *:\=\s *enddef\> "
536545 \ contains= vimDef
537546 \ extend fold keepend transparent
@@ -573,14 +582,20 @@ if s:vim9script
573582
574583 " Methods {{{3
575584 syn match vim9MethodDef contained " \< def\> " skipwhite nextgroup =vim9MethodDefName,vim9ConstructorDefName
576- syn match vim9MethodDefName contained " \<\h\w *\> " nextgroup =vim9MethodDefParams contains =@vim9MethodName
585+ syn match vim9MethodDefName contained " \<\h\w *\> " nextgroup =vim9MethodDefParams,vim9MethodDefTypeParams contains =@vim9MethodName
577586 syn region vim9MethodDefParams contained
578587 \ matchgroup= Delimiter start = " (" end = " )"
579588 \ skipwhite skipnl nextgroup= vim9MethodDefBody,vim9MethodDefComment,vimEnddef,vim9MethodDefReturnType,vimCommentError
580589 \ contains= vimDefParam,vim9Comment,vimFunctionParamEquals
590+ syn region vim9MethodDefTypeParams contained
591+ \ matchgroup= Delimiter
592+ \ start = " <"
593+ \ end = " >"
594+ \ nextgroup= vim9MethodDefParams
595+ \ contains= vim9DefTypeParam
581596
582597 syn match vim9ConstructorDefName contained " \< _\= new\w *\> "
583- \ nextgroup= vim9ConstructorDefParams
598+ \ nextgroup= vim9ConstructorDefParams,vim9ConstuctorDefTypeParams
584599 \ contains= @v im9MethodName
585600 syn match vim9ConstructorDefParam contained " \<\% (this\.\)\=\h\w *\> "
586601 \ skipwhite nextgroup= vimParamType,vimFunctionParamEquals
@@ -589,6 +604,12 @@ if s:vim9script
589604 \ matchgroup= Delimiter start = " (" end = " )"
590605 \ skipwhite skipnl nextgroup= vim9MethodDefBody,vim9MethodDefComment,vimEnddef,vimCommentError
591606 \ contains= vim9ConstructorDefParam,vim9Comment,vimFunctionParamEquals
607+ syn region vim9ConstuctorDefTypeParams contained
608+ \ matchgroup= Delimiter
609+ \ start = " <"
610+ \ end = " >"
611+ \ nextgroup= vim9ConstructorDefParams
612+ \ contains= vim9DefTypeParam
592613
593614 syn region vim9MethodDefReturnType contained
594615 \ start = " :\% (\s\| \n \)\@ ="
@@ -622,8 +643,11 @@ if s:vim9script
622643 syn cluster vim9MethodName contains =vim9MethodName,vim9MethodNameError
623644
624645 if exists (" g:vimsyn_folding" ) && g: vimsyn_folding = ~# ' f'
625- syn region vim9MethodDefFold contained start =" \% (^\s *\% (:\= static\s\+\)\=\)\@ 16<=:\= def\s\+\h\i *(" end =" ^\s *:\= enddef\> " contains =vim9MethodDef fold keepend extend transparent
626- syn region vim9MethodDefFold contained start =" ^\s *:\= def\s\+ _\= new\i *(" end =" ^\s *:\= enddef\> " contains =vim9MethodDef fold keepend extend transparent
646+ syn region vim9MethodDefFold contained
647+ \ start = " \% (^\s *\% (:\= static\s\+\)\=\)\@ 16<=:\= def\s\+\h\w *[<(]"
648+ \ end = " ^\s *:\= enddef\> "
649+ \ contains= vim9MethodDef
650+ \ fold keepend extend transparent
627651 endif
628652
629653 syn cluster vim9MethodDef contains =vim9MethodDef,vim9MethodDefFold
@@ -703,7 +727,7 @@ if s:vim9script
703727 syn match vim9InterfaceName contained " \<\u\w *\> " skipwhite skipnl nextgroup =vim9Extends
704728
705729 syn keyword vim9AbstractDef contained def skipwhite nextgroup =vim9AbstractDefName
706- syn match vim9AbstractDefName contained " \<\h\w *\> " skipwhite nextgroup =vim9AbstractDefParams contains =@vim9MethodName
730+ syn match vim9AbstractDefName contained " \<\h\w *\> " skipwhite nextgroup =vim9AbstractDefParams,vim9AbstractDefTypeParams contains =@vim9MethodName
707731 syn region vim9AbstractDefParams contained
708732 \ matchgroup= Delimiter start = " (" end = " )"
709733 \ skipwhite skipnl nextgroup= vimDefComment,vim9AbstractDefReturnType,vimCommentError
@@ -713,6 +737,12 @@ if s:vim9script
713737 \ skipwhite skipnl nextgroup= vimDefComment,vimCommentError
714738 \ contains= vimTypeSep
715739 \ transparent
740+ syn region vim9AbstractDefTypeParams contained
741+ \ matchgroup= Delimiter
742+ \ start = " <"
743+ \ end = " >"
744+ \ nextgroup= vim9AbstractDefParams
745+ \ contains= vim9DefTypeParam
716746
717747 VimFoldi syn region vim9InterfaceBody start =" \< interface\> " matchgroup =vimCommand end =" \< endinterface\> " contains =@vim9InterfaceBodyList transparent
718748
@@ -1431,7 +1461,7 @@ syn match vimBracket contained "[\\<>]"
14311461syn case match
14321462
14331463" User Command Highlighting: {{{2
1434- syn match vimUsrCmd ' ^\s *\z s\u\% (\w *\)\@ >\% ([.(#[]\|\s\+\% ([-+*/%]\=\|\.\.\) =\)\@ !'
1464+ syn match vimUsrCmd ' ^\s *\z s\u\% (\w *\)\@ >\% ([< .(#[]\|\s\+\% ([-+*/%]\=\|\.\.\) =\)\@ !'
14351465
14361466" Vim user commands
14371467
@@ -2088,18 +2118,26 @@ unlet s:interfaces
20882118" Function Call Highlighting: {{{2
20892119" (following Gautam Iyer's suggestion)
20902120" ==========================
2091- syn match vimFunc contained " \<\l\w *\z e\s *(" skipwhite nextgroup =vimOperParen contains =vimFuncName
2092- syn match vimUserFunc contained " \.\@ 1<=\l\w *\z e\s *(" skipwhite nextgroup =vimOperParen
2093- syn match vimUserFunc contained " \<\% ([[:upper:]_]\|\% (\h\w *\.\)\+\h\)\w *\z e\s *(" skipwhite nextgroup =vimOperParen contains =vim9MethodName,vim9Super,vim9This
2094- syn match vimUserFunc contained " \<\% (g:\)\=\% (\h\w *#\)\+\h\w *\z e\s *(" skipwhite nextgroup =vimOperParen contains =vimVarScope
2095- syn match vimUserFunc contained " \% (\< [sgbwtlav]:\| <[sS][iI][dD]>\)\% (\h\w *\.\) *\h\w *\z e\s *(" skipwhite nextgroup =vimOperParen contains =vimVarScope,vimNotation
2121+ syn match vimFunc contained " \<\l\w *\z e\s *(" skipwhite nextgroup =vimOperParen contains =vimFuncName
2122+ syn match vimUserFunc contained " \.\@ 1<=\l\w *\z e\% ( \ s *(\| <.*>( \) " skipwhite nextgroup =vimOperParen,vim9TypeArgs
2123+ syn match vimUserFunc contained " \<\% ([[:upper:]_]\|\% (\h\w *\.\)\+\h\)\w *\z e\% ( \ s *(\| <.*>( \) " skipwhite nextgroup =vimOperParen,vim9TypeArgs contains =vim9MethodName,vim9Super,vim9This
2124+ syn match vimUserFunc contained " \<\% (g:\)\=\% (\h\w *#\)\+\h\w *\z e\% ( \ s *(\| <.*>( \) " skipwhite nextgroup =vimOperParen contains =vimVarScope
2125+ syn match vimUserFunc contained " \% (\< [sgbwtlav]:\| <[sS][iI][dD]>\)\% (\h\w *\.\) *\h\w *\z e\% ( \ s *(\| <.*>( \) " skipwhite nextgroup =vimOperParen,vim9TypeArgs contains =vimVarScope,vimNotation
20962126
2097- Vim9 syn match vim9UserFunc " ^\s *\z s\% ([sgbwtv]:\| <[sS][iI][dD]>\)\=\% (\h\w *[.#]\) *\h\w *\z e( " skipwhite nextgroup= vimOperParen contains= vimVarScope,vimNotation,vim9MethodName,vim9Super,vim9This
2098- Vim9 syn match vim9Func " ^\s *\z s\l\w *\z e(" skipwhite nextgroup= vimOperParen contains= vimFuncName
2127+ Vim9 syn match vim9UserFunc " ^\s *\z s\% ([sgbwtv]:\| <[sS][iI][dD]>\)\=\% (\h\w *[.#]\) *\h\w *\z e[<(] " skipwhite nextgroup= vimOperParen,vim9TypeArgs contains= vimVarScope,vimNotation,vim9MethodName,vim9Super,vim9This
2128+ Vim9 syn match vim9Func " ^\s *\z s\l\w *\z e(" skipwhite nextgroup= vimOperParen contains= vimFuncName
20992129
21002130syn cluster vimFunc contains =vimFunc,vimUserFunc
21012131syn cluster vim9Func contains =vim9Func,vim9UserFunc
21022132
2133+ syn region vim9TypeArgs contained
2134+ \ matchgroup= Delimiter
2135+ \ start = " <\z e\a "
2136+ \ end = " >"
2137+ \ nextgroup= vimOperParen
2138+ \ contains= @v imType
2139+ \ oneline
2140+
21032141" Beginners - Patterns that involve ^ {{{2
21042142" =========
21052143Vim9 syn region vim9LineComment start = + ^[ \t :]* \z s#.* $ + skip = + \n \s * \\ \| \n \s * #\\ + end = " $" contains= @v imCommentGroup,vimCommentString,vim9CommentTitle extend
0 commit comments