diff --git a/runtime/syntax/vim.vim b/runtime/syntax/vim.vim index 76d4e4e585..db65c1d8c2 100644 --- a/runtime/syntax/vim.vim +++ b/runtime/syntax/vim.vim @@ -386,8 +386,16 @@ syn match vimDef "\" skipwhite nextgroup=vimCmdSep,vimComment,vimFuncPatt syn match vimFunction "\!\=\s*\%(<[sS][iI][dD]>\|[sg]:\)\=\%(\i\|[#.]\|{.\{-1,}}\)\+" contains=@vimFuncList skipwhite nextgroup=vimFuncParams syn match vimDef "\!\=\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" @@ -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 "\" syn region vimCompoundType contained matchgroup=vimType start="\" +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 "\" @@ -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="\" \ 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