vim-patch:dd3f1c0: runtime(vim): Update base-syntax, match multiline return types

fixes vim/vim#14442.
closes: vim/vim#16914

dd3f1c0dda

Co-authored-by: Doug Kearns <dougkearns@gmail.com>
This commit is contained in:
zeertzjq
2025-04-18 14:44:55 +08:00
parent e2fa151f9c
commit 700840f4b7

View File

@@ -386,8 +386,16 @@ syn match vimDef "\<def\>" skipwhite nextgroup=vimCmdSep,vimComment,vimFuncPatt
syn match vimFunction "\<fu\%[nction]\>!\=\s*\%(<[sS][iI][dD]>\|[sg]:\)\=\%(\i\|[#.]\|{.\{-1,}}\)\+" contains=@vimFuncList skipwhite nextgroup=vimFuncParams
syn match vimDef "\<def\>!\=\s*\%(<[sS][iI][dD]>\|[sg]:\)\=\%(\i\|[#.]\|{.\{-1,}}\)\+" contains=@vimDefList nextgroup=vimDefParams
syn match vimFuncComment contained +".*+ skipwhite skipempty nextgroup=vimFuncBody,vimEndfunction
syn match vimDefComment contained "#.*" skipwhite skipempty nextgroup=vimDefBody,vimEnddef
syn region vimFuncComment contained
\ start=+".*+
\ skip=+\n\s*\\\|\n\s*"\\ +
\ end="$"
\ skipwhite skipempty nextgroup=vimFuncBody,vimEndfunction
syn region vimDefComment contained
\ start="#.*"
\ skip=+\n\s*\\\|\n\s*#\\ +
\ end="$"
\ skipwhite skipempty nextgroup=vimDefBody,vimEnddef
syn match vimFuncBang contained "!"
syn match vimFuncSID contained "\c<sid>"
@@ -419,15 +427,24 @@ syn match vimFuncBlank contained "\s\+"
" Types: {{{2
" =====
syn region vimReturnType contained start=":\s" end="$" matchgroup=vim9Comment end="\ze[#"]" skipwhite skipempty nextgroup=vimDefBody,vimDefComment,vimEnddef,vimCommentError contains=vimTypeSep transparent
syn region vimReturnType contained
\ start=":\%(\s\|\n\)\@="
\ skip=+\n\s*\\\|\n\s*#\\ \|^\s*#\\ +
\ end="$"
\ matchgroup=vim9Comment
"\ allow for legacy script tail comment error
\ end="\ze[#"]"
\ skipwhite skipempty nextgroup=vimDefBody,vimDefComment,vimEnddef,vimCommentError
\ contains=@vim9Continue,@vimType
\ transparent
syn match vimParamType contained ":\s" skipwhite skipnl nextgroup=@vimType contains=vimTypeSep
syn match vimTypeSep contained ":\s\@=" skipwhite nextgroup=@vimType
syn match vimTypeSep contained ":\%(\s\|\n\)\@=" skipwhite nextgroup=@vimType
syn keyword vimType contained any blob bool channel float job number string void
syn match vimType contained "\<func\>"
syn region vimCompoundType contained matchgroup=vimType start="\<func(" end=")" nextgroup=vimTypeSep contains=@vimType oneline transparent
syn region vimCompoundType contained matchgroup=vimType start="\<\%(list\|dict\)<" end=">" contains=@vimType oneline transparent
syn match vimUserType contained "\<\u\w*\>"
syn match vimUserType contained "\<\%(\h\w*\.\)*\u\w*\>"
syn cluster vimType contains=vimType,vimCompoundType,vimUserType
@@ -440,7 +457,7 @@ if s:vim9script
syn match vim9MethodDefName contained "\<\h\w*\>" nextgroup=vim9MethodDefParams contains=@vim9MethodName
syn region vim9MethodDefParams contained
\ matchgroup=Delimiter start="(" end=")"
\ skipwhite skipnl nextgroup=vim9MethodDefBody,vimDefComment,vimEnddef,vim9MethodDefReturnType,vimCommentError
\ skipwhite skipnl nextgroup=vim9MethodDefBody,vim9MethodDefComment,vimEnddef,vim9MethodDefReturnType,vimCommentError
\ contains=vimDefParam,vim9Comment,vimFuncParamEquals
syn match vim9ConstructorDefName contained "\<new\w*\>"
@@ -451,14 +468,25 @@ if s:vim9script
\ contains=vim9This,vimOper
syn region vim9ConstructorDefParams contained
\ matchgroup=Delimiter start="(" end=")"
\ skipwhite skipnl nextgroup=vim9MethodDefBody,vimDefComment,vimEnddef,vimCommentError
\ skipwhite skipnl nextgroup=vim9MethodDefBody,vim9MethodDefComment,vimEnddef,vimCommentError
\ contains=vim9ConstructorDefParam,vim9Comment,vimFuncParamEquals
syn region vim9MethodDefReturnType contained
\ start=":\s" end="$" matchgroup=vim9Comment end="\ze[#"]"
\ skipwhite skipnl nextgroup=vim9MethodDefBody,vimDefComment,vimCommentError
\ contains=vimTypeSep
\ start=":\%(\s\|\n\)\@="
\ skip=+\n\s*\\\|\n\s*#\\ \|^\s*#\\ +
\ end="$"
\ matchgroup=vim9Comment
\ end="\ze#"
\ skipwhite skipnl nextgroup=vim9MethodDefBody,vim9MethodDefComment,vimEnddef,vimCommentError
\ contains=@vim9Continue,vimType,vimTypeSep
\ transparent
syn region vim9MethodDefComment contained
\ start="#.*"
\ skip=+\n\s*\\\|\n\s*#\\ +
\ end="$"
\ skipwhite skipempty nextgroup=vim9MethodDefBody,vimEnddef
syn region vim9MethodDefBody contained
\ start="^.\=" matchgroup=vimCommand end="\<enddef\>"
\ skipwhite nextgroup=vimCmdSep,vim9Comment,vimCommentError
@@ -1700,6 +1728,7 @@ if !exists("skip_vim_syntax_inits")
hi def link vim9LhsVariable vimVar
hi def link vim9LineComment vimComment
hi def link vim9MethodDef vimCommand
hi def link vim9MethodDefComment vimDefComment
hi def link vim9MethodNameError vimFunctionError
hi def link vim9Null Constant
hi def link vim9Public vimCommand