From f25ffc43a78da13719d9646e5ccb308a791278b6 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 10 Nov 2024 09:50:59 +0800 Subject: [PATCH 1/4] vim-patch:dfcef89: runtime(vim): Distinguish Vim9 constructor definitions from the :new ex command (vim/vim#14050) With the arrival of Vim9 classes, the syntax must allow for _new_ constructors; multiple constructor definitions are supported for a class, provided distinct suffix-names are used. Currently, the defined constructors match either vimCommand or vimFunctionError (for any newBar). For example: ------------------------------------------------------------ vim9script class Foo def new() enddef def newBar() enddef endclass ------------------------------------------------------------ Since every constructor is required to bear a lower-cased _new_ prefix name, it should suffice to distinguish them from functions, and so there are no new highlight or syntax groups introduced. https://github.com/vim/vim/commit/dfcef890cbdd3ec26de040b2e26d77444dc46862 Co-authored-by: Aliaksei Budavei <32549825+zzzyxwvut@users.noreply.github.com> --- runtime/syntax/vim.vim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/runtime/syntax/vim.vim b/runtime/syntax/vim.vim index 6e38076d35..e5623528ea 100644 --- a/runtime/syntax/vim.vim +++ b/runtime/syntax/vim.vim @@ -679,7 +679,8 @@ syn match vimUsrCmd '^\s*\zs\u\%(\w*\)\@>\%([(#[]\|\s\+\%([-+*/%]\=\|\.\.\)=\)\@ " Errors And Warnings: {{{2 " ==================== if !exists("g:vimsyn_noerror") && !exists("g:vimsyn_novimfunctionerror") - syn match vimFunctionError "\s\zs[a-z0-9]\i\{-}\ze\s*(" contained contains=vimFuncKey,vimFuncBlank + " TODO: The new-prefix exception should only apply to constructor definitions. + syn match vimFunctionError "\s\zs\%(new\)\@![a-z0-9]\i\{-}\ze\s*(" contained contains=vimFuncKey,vimFuncBlank syn match vimFunctionError "\s\zs\%(<[sS][iI][dD]>\|[sSgGbBwWtTlL]:\)\d\i\{-}\ze\s*(" contained contains=vimFuncKey,vimFuncBlank syn match vimElseIfErr "\" syn match vimBufnrWarn /\ Date: Sun, 10 Nov 2024 09:56:04 +0800 Subject: [PATCH 2/4] vim-patch:80aabaa: runtime(vim): Distinguish Vim9 builtin object methods from namesake builtin functions (vim/vim#14348) Currently, the overriding object method definitions are matched as vimFunctionError (:help builtin-object-methods, v9.1.0148). For example: ------------------------------------------------------------ vim9script class Test def string(): string return "Test" enddef endclass echo string(Test.new()) == Test.new().string() ------------------------------------------------------------ Instead, let's introduce a new syntax group vimMethodName and make these methods its members. In order to emphasise the link between the overriding methods and the overridden functions for highlighting, vimMethodName is linked by default to vimFuncName. https://github.com/vim/vim/commit/80aabaab6636faa7cec461acc4b1fcc3a4c89376 Co-authored-by: Aliaksei Budavei <32549825+zzzyxwvut@users.noreply.github.com> --- runtime/syntax/vim.vim | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/runtime/syntax/vim.vim b/runtime/syntax/vim.vim index e5623528ea..b2a703eba9 100644 --- a/runtime/syntax/vim.vim +++ b/runtime/syntax/vim.vim @@ -274,7 +274,7 @@ 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 vimDef "\!\=\s*\%(<[sS][iI][dD]>\|[sg]:\)\=\%(\i\|[#.]\|{.\{-1,}}\)\+" contains=@vimDefList,vimMethodName nextgroup=vimDefParams syn match vimFuncComment contained +".*+ skipwhite skipempty nextgroup=vimFuncBody,vimEndfunction syn match vimDefComment contained "#.*" skipwhite skipempty nextgroup=vimDefBody,vimEnddef @@ -284,6 +284,7 @@ syn match vimFuncSID contained "\c" syn match vimFuncSID contained "\<[sg]:" syn keyword vimFuncKey contained fu[nction] syn keyword vimDefKey contained def +syn keyword vimMethodName contained empty len string syn region vimFuncParams contained matchgroup=Delimiter start="(" skip=+\n\s*\\\|\n\s*"\\ + end=")" skipwhite skipempty nextgroup=vimFuncBody,vimFuncComment,vimEndfunction,vimFuncMod,vim9CommentError contains=vimFuncParam,@vimContinue syn region vimDefParams contained matchgroup=Delimiter start="(" end=")" skipwhite skipempty nextgroup=vimDefBody,vimDefComment,vimEnddef,vimReturnType,vimCommentError contains=vimDefParam,vim9Comment,vimFuncParamEquals @@ -668,7 +669,7 @@ syn case match " (following Gautam Iyer's suggestion) " ========================== syn match vimFunc "\%(\%([sSgGbBwWtTlL]:\|<[sS][iI][dD]>\)\=\%(\w\+\.\)*\I[a-zA-Z0-9_.]*\)\ze\s*(" contains=vimFuncEcho,vimFuncName,vimUserFunc,vimExecute -syn match vimUserFunc contained "\%(\%([sSgGbBwWtTlL]:\|<[sS][iI][dD]>\)\=\%(\w\+\.\)*\I[a-zA-Z0-9_.]*\)\|\<\u[a-zA-Z0-9.]*\>\|\" contains=vimNotation +syn match vimUserFunc contained "\%(\%([sSgGbBwWtTlL]:\|<[sS][iI][dD]>\)\=\%(\w\+\.\)*\I[a-zA-Z0-9_.]*\)\|\<\u[a-zA-Z0-9.]*\>\|\" contains=vimNotation,vimMethodName syn keyword vimFuncEcho contained ec ech echo syn match vimMap "\\%([(#[]\|\s\+\%([-+*/%]\=\|\.\.\)=\)\@ " ==================== if !exists("g:vimsyn_noerror") && !exists("g:vimsyn_novimfunctionerror") " TODO: The new-prefix exception should only apply to constructor definitions. - syn match vimFunctionError "\s\zs\%(new\)\@![a-z0-9]\i\{-}\ze\s*(" contained contains=vimFuncKey,vimFuncBlank + " TODO: The |builtin-object-methods| exception should only apply to method + " definitions. + syn match vimFunctionError "\s\zs\%(empty\|len\|new\|string\)\@![a-z0-9]\i\{-}\ze\s*(" contained contains=vimFuncKey,vimFuncBlank syn match vimFunctionError "\s\zs\%(<[sS][iI][dD]>\|[sSgGbBwWtTlL]:\)\d\i\{-}\ze\s*(" contained contains=vimFuncKey,vimFuncBlank syn match vimElseIfErr "\" syn match vimBufnrWarn /\ Date: Sun, 10 Nov 2024 10:00:35 +0800 Subject: [PATCH 3/4] vim-patch:818c641: runtime(vim): Update base-syntax file, improve class, enum and interface highlighting - Enable folding of class, enum and interface declarations. - Highlight constructor names with the Function highlight group, like other special methods. - Mark function definitions using special method names as errors. - Highlight :type arguments. fixes: vim/vim#14393#issuecomment-2042796198. closes: vim/vim#13810 https://github.com/vim/vim/commit/818c641b6fac73b574a2b760213f515cee9a3c8e Co-authored-by: Doug Kearns --- runtime/doc/syntax.txt | 2 +- runtime/syntax/vim.vim | 177 ++++++++++++++++++++++++++++++++++++----- 2 files changed, 158 insertions(+), 21 deletions(-) diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt index 9d7dbd39c4..b9daff84f3 100644 --- a/runtime/doc/syntax.txt +++ b/runtime/doc/syntax.txt @@ -3493,7 +3493,7 @@ This option is disabled by default. Some folding is now supported with when 'foldmethod' is set to "syntax": > g:vimsyn_folding == 0 or doesn't exist: no syntax-based folding - g:vimsyn_folding =~ 'a' : augroups + g:vimsyn_folding =~ 'a' : fold augroups g:vimsyn_folding =~ 'f' : fold functions g:vimsyn_folding =~ 'h' : fold heredocs g:vimsyn_folding =~ 'l' : fold Lua script diff --git a/runtime/syntax/vim.vim b/runtime/syntax/vim.vim index b2a703eba9..602e22b258 100644 --- a/runtime/syntax/vim.vim +++ b/runtime/syntax/vim.vim @@ -74,12 +74,22 @@ syn case match com! -nargs=* Vim9 execute s:vim9script ? "" : "contained" com! -nargs=* VimL execute s:vim9script ? "contained" : "" -if exists("g:vimsyn_folding") && g:vimsyn_folding =~# '[afhHlmpPrt]' +if exists("g:vimsyn_folding") && g:vimsyn_folding =~# '[acefhiHlmpPrt]' if g:vimsyn_folding =~# 'a' com! -nargs=* VimFolda fold else com! -nargs=* VimFolda endif + if g:vimsyn_folding =~# 'c' + com! -nargs=* VimFoldc fold + else + com! -nargs=* VimFoldc + endif + if g:vimsyn_folding =~# 'e' + com! -nargs=* VimFolde fold + else + com! -nargs=* VimFolde + endif if g:vimsyn_folding =~# 'f' com! -nargs=* VimFoldf fold else @@ -95,6 +105,11 @@ if exists("g:vimsyn_folding") && g:vimsyn_folding =~# '[afhHlmpPrt]' else com! -nargs=* VimFoldH endif + if g:vimsyn_folding =~# 'i' + com! -nargs=* VimFoldi fold + else + com! -nargs=* VimFoldi + endif if g:vimsyn_folding =~# 'l' com! -nargs=* VimFoldl fold else @@ -127,7 +142,10 @@ if exists("g:vimsyn_folding") && g:vimsyn_folding =~# '[afhHlmpPrt]' endif else com! -nargs=* VimFolda + com! -nargs=* VimFoldc + com! -nargs=* VimFolde com! -nargs=* VimFoldf + com! -nargs=* VimFoldi com! -nargs=* VimFoldh com! -nargs=* VimFoldH com! -nargs=* VimFoldl @@ -177,8 +195,8 @@ syn match vimNumber '\%(^\|\A\)\zs#\x\{6}' skipwhite nextgroup=vimGlobal,vimSub syn case match " All vimCommands are contained by vimIsCommand. {{{2 -syn cluster vimCmdList contains=vimAbb,vimAddress,vimAutoCmd,vimAugroup,vimBehave,vimCall,vimCatch,vimConst,vimDef,vimDelcommand,@vimEcho,vimEnddef,vimEndfunction,vimExecute,vimIsCommand,vimExtCmd,vimFor,vimFunction,vimFuncFold,vimGlobal,vimHighlight,vimLet,vimLoadkeymap,vimMap,vimMark,vimMatch,vimNotFunc,vimNorm,vimSet,vimSleep,vimSyntax,vimThrow,vimUnlet,vimUnmap,vimUserCmd,vimMenu,vimMenutranslate,@vim9CmdList -syn cluster vim9CmdList contains=vim9Const,vim9Final,vim9For,vim9Var +syn cluster vimCmdList contains=vimAbb,vimAddress,vimAutoCmd,vimAugroup,vimBehave,vimCall,vimCatch,vimConst,vimDef,vimDefFold,vimDelcommand,@vimEcho,vimEnddef,vimEndfunction,vimExecute,vimIsCommand,vimExtCmd,vimFor,vimFunction,vimFuncFold,vimGlobal,vimHighlight,vimLet,vimLoadkeymap,vimMap,vimMark,vimMatch,vimNotFunc,vimNorm,vimSet,vimSleep,vimSyntax,vimThrow,vimUnlet,vimUnmap,vimUserCmd,vimMenu,vimMenutranslate,@vim9CmdList +syn cluster vim9CmdList contains=vim9Class,vim9Const,vim9Enum,vim9Export,vim9Final,vim9For,vim9Interface,vim9Type,vim9Var syn match vimCmdSep "[:|]\+" skipwhite nextgroup=@vimCmdList,vimSubst1 syn match vimIsCommand "\<\%(\h\w*\|[23]mat\%[ch]\)\>" contains=vimCommand syn match vimBang contained "!" @@ -220,6 +238,12 @@ syn keyword vimThrow th[row] skipwhite nextgroup=@vimExprList syn keyword vimCatch cat[ch] skipwhite nextgroup=vimCatchPattern syn region vimCatchPattern contained matchgroup=Delimiter start="\z([!#$%&'()*+,-./:;<=>?@[\]^_`{}~]\)" skip="\\\\\|\\\z1" end="\z1" contains=@vimSubstList oneline +" Export {{{2 +" ====== +if s:vim9script + syn keyword vim9Export export skipwhite nextgroup=vim9Abstract,vim9ClassBody,vim9Const,vim9Def,vim9EnumBody,vim9Final,vim9InterfaceBody,vim9Type,vim9Var +endif + " Filetypes {{{2 " ========= syn match vimFiletype "\" skipwhite nextgroup=vimCmdSep,vimCommen syn match vimDef "\" skipwhite nextgroup=vimCmdSep,vimComment,vimFuncPattern contains=vimDefKey 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,vimMethodName nextgroup=vimDefParams +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 @@ -284,7 +307,6 @@ syn match vimFuncSID contained "\c" syn match vimFuncSID contained "\<[sg]:" syn keyword vimFuncKey contained fu[nction] syn keyword vimDefKey contained def -syn keyword vimMethodName contained empty len string syn region vimFuncParams contained matchgroup=Delimiter start="(" skip=+\n\s*\\\|\n\s*"\\ + end=")" skipwhite skipempty nextgroup=vimFuncBody,vimFuncComment,vimEndfunction,vimFuncMod,vim9CommentError contains=vimFuncParam,@vimContinue syn region vimDefParams contained matchgroup=Delimiter start="(" end=")" skipwhite skipempty nextgroup=vimDefBody,vimDefComment,vimEnddef,vimReturnType,vimCommentError contains=vimDefParam,vim9Comment,vimFuncParamEquals @@ -301,9 +323,8 @@ syn match vimEndfunction "\" skipwhite nextgroup=vimCmdSep,vim syn match vimEnddef "\" skipwhite nextgroup=vimCmdSep,vim9Comment,vimCommentError if exists("g:vimsyn_folding") && g:vimsyn_folding =~# 'f' - syn region vimFuncFold start="\!\=\s*\%(<[sS][iI][dD]>\|[sg]:\)\=\%(\i\|[#.]\|{.\{-1,}}\)\+\s*(" end="\" contains=vimFunction fold keepend extend transparent - syn region vimFuncFold start="\!\=\s*\%(<[sS][iI][dD]>\|[sg]:\)\=\%(\i\|[#.]\)\+(" end="\" contains=vimDef fold keepend extend transparent - syn region vimFuncFold start="\" @@ -324,6 +345,100 @@ syn match vimUserType contained "\<\u\w*\>" syn cluster vimType contains=vimType,vimCompoundType,vimUserType +" Classes, Enums And Interfaces: {{{2 +" ============================= + +if s:vim9script + " Methods {{{3 + syn match vim9MethodDef contained "\" skipwhite nextgroup=vim9MethodDefName + 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 + \ contains=vimDefParam,vim9Comment,vimFuncParamEquals + syn region vim9MethodDefReturnType contained + \ start=":\s" end="$" matchgroup=vim9Comment end="\ze[#"]" + \ skipwhite skipnl nextgroup=vim9MethodDefBody,vimDefComment,vimCommentError + \ contains=vimTypeSep + \ transparent + syn region vim9MethodDefBody contained + \ start="^.\=" matchgroup=vimCommand end="\" + \ skipwhite nextgroup=vimCmdSep,vim9Comment,vimCommentError + \ contains=@vim9MethodDefBodyList + + syn cluster vim9MethodDefBodyList contains=@vimDefBodyList,vim9This,vim9Super + + if !exists("g:vimsyn_noerror") && !exists("g:vimsyn_novimfunctionerror") + syn match vim9MethodNameError contained "\<[a-z0-9]\i\>" + endif + syn match vim9MethodName contained "\" + syn keyword vim9MethodName contained empty len string + + syn cluster vim9MethodName contains=vim9MethodName,vim9MethodNameError + + if exists("g:vimsyn_folding") && g:vimsyn_folding =~# 'f' + syn region vim9MethodDefFold contained start="\%(^\s*\%(:\=static\s\+\)\=\)\@16<=:\=def\s\+\h\i*(" end="^\s*:\=enddef\>" contains=vim9MethodDef fold keepend extend transparent + syn region vim9MethodDefFold contained start="^\s*:\=def\s\+new\i*(" end="^\s*:\=enddef\>" contains=vim9MethodDef fold keepend extend transparent + endif + + syn cluster vim9MethodDef contains=vim9MethodDef,vim9MethodDefFold + + " Classes {{{3 + syn cluster vim9ClassBodyList contains=vim9Abstract,vim9Class,vim9Comment,vim9LineComment,@vim9Continue,@vimExprList,vim9Extends,vim9Implements,@vim9MethodDef,vim9Public,vim9Static,vim9Const,vim9Final,vim9This,vim9Super,vim9Var + + syn match vim9Class contained "\" skipwhite nextgroup=vim9ClassName + syn match vim9ClassName contained "\<\u\w*\>" skipwhite skipnl nextgroup=vim9Extends,vim9Implements + syn match vim9SuperClass contained "\<\u\w*\>" skipwhite skipnl nextgroup=vim9Implements + syn match vim9ImplementedInterface contained "\<\u\w*\>" skipwhite skipnl nextgroup=vim9InterfaceListComma,vim9Extends + syn match vim9InterfaceListComma contained "," skipwhite skipnl nextgroup=vim9ImplementedInterface + syn keyword vim9Abstract abstract skipwhite skipnl nextgroup=vim9ClassBody,vim9AbstractDef + syn keyword vim9Extends contained extends skipwhite skipnl nextgroup=vim9SuperClass + syn keyword vim9Implements contained implements skipwhite skipnl nextgroup=vim9ImplementedInterface + syn keyword vim9Public contained public + syn keyword vim9Static contained static + syn keyword vim9This contained this + syn keyword vim9Super contained super + + VimFoldc syn region vim9ClassBody start="\" matchgroup=vimCommand end="\" contains=@vim9ClassBodyList transparent + + " Enums {{{3 + syn cluster vim9EnumBodyList contains=vim9Comment,vim9LineComment,@vim9Continue,vim9Enum,vim9Implements,@vim9MethodDef,vim9Const,vim9Final,vim9Var + + syn match vim9Enum contained "\" skipwhite nextgroup=vim9EnumName + syn match vim9EnumName contained "\<\u\w*\>" skipwhite skipnl nextgroup=vim9Implements + + VimFolde syn region vim9EnumBody start="\" matchgroup=vimCommand end="\" contains=@vim9EnumBodyList transparent + + " Interfaces {{{3 + " TODO: limit to decl only - no init values + syn cluster vim9InterfaceBodyList contains=vim9Comment,vim9LineComment,@vim9Continue,vim9Extends,vim9Interface,vim9AbstractDef,vim9Var + + syn match vim9Interface contained "\" skipwhite nextgroup=vim9InterfaceName + syn match vim9InterfaceName contained "\<\u\w*\>" skipwhite skipnl nextgroup=vim9Extends + + syn keyword vim9AbstractDef contained def skipwhite nextgroup=vim9AbstractDefName + syn match vim9AbstractDefName contained "\<\h\w*\>" skipwhite nextgroup=vim9AbstractDefParams contains=@vim9MethodName + syn region vim9AbstractDefParams contained + \ matchgroup=Delimiter start="(" end=")" + \ skipwhite skipnl nextgroup=vimDefComment,vim9AbstractDefReturnType,vimCommentError + \ contains=vimDefParam,vim9Comment,vimFuncParamEquals + syn region vim9AbstractDefReturnType contained + \ start=":\s" end="$" matchgroup=vim9Comment end="\ze[#"]" + \ skipwhite skipnl nextgroup=vimDefComment,vimCommentError + \ contains=vimTypeSep + \ transparent + + VimFoldi syn region vim9InterfaceBody start="\" matchgroup=vimCommand end="\" contains=@vim9InterfaceBodyList transparent + + " type {{{3 + syn match vim9Type "\" skipwhite nextgroup=vim9TypeAlias,vim9TypeAliasError + syn match vim9TypeAlias contained "\<\u\w*\>" skipwhite nextgroup=vim9TypeEquals + syn match vim9TypeEquals contained "=" skipwhite nextgroup=@vimType + if !exists("g:vimsyn_noerror") && !exists("g:vimsyn_notypealiaserror") + syn match vim9TypeAliasError contained "\<\U\w*" + endif +endif + " Keymaps: {{{2 " ======= @@ -542,7 +657,7 @@ Vim9 syn keyword vim9Const const skipwhite nextgroup=vim9Variable,vim9VariableLi Vim9 syn keyword vim9Final final skipwhite nextgroup=vim9Variable,vim9VariableList Vim9 syn keyword vim9Var var skipwhite nextgroup=vim9Variable,vim9VariableList -syn match vim9Variable contained "\<\h\w*\>" skipwhite nextgroup=vimTypeSep,vimLetHereDoc +syn match vim9Variable contained "\<\h\w*\>" skipwhite nextgroup=vimTypeSep,vimLetHereDoc,vimOper syn region vim9VariableList contained start="\[" end="]" contains=vim9Variable,@vimContinue " For: {{{2 @@ -669,7 +784,7 @@ syn case match " (following Gautam Iyer's suggestion) " ========================== syn match vimFunc "\%(\%([sSgGbBwWtTlL]:\|<[sS][iI][dD]>\)\=\%(\w\+\.\)*\I[a-zA-Z0-9_.]*\)\ze\s*(" contains=vimFuncEcho,vimFuncName,vimUserFunc,vimExecute -syn match vimUserFunc contained "\%(\%([sSgGbBwWtTlL]:\|<[sS][iI][dD]>\)\=\%(\w\+\.\)*\I[a-zA-Z0-9_.]*\)\|\<\u[a-zA-Z0-9.]*\>\|\" contains=vimNotation,vimMethodName +syn match vimUserFunc contained "\%(\%([sSgGbBwWtTlL]:\|<[sS][iI][dD]>\)\=\%(\w\+\.\)*\I[a-zA-Z0-9_.]*\)\|\<\u[a-zA-Z0-9.]*\>\|\" contains=vimNotation,vim9MethodName syn keyword vimFuncEcho contained ec ech echo syn match vimMap "\\%([(#[]\|\s\+\%([-+*/%]\=\|\.\.\)=\)\@ " Errors And Warnings: {{{2 " ==================== if !exists("g:vimsyn_noerror") && !exists("g:vimsyn_novimfunctionerror") - " TODO: The new-prefix exception should only apply to constructor definitions. - " TODO: The |builtin-object-methods| exception should only apply to method - " definitions. - syn match vimFunctionError "\s\zs\%(empty\|len\|new\|string\)\@![a-z0-9]\i\{-}\ze\s*(" contained contains=vimFuncKey,vimFuncBlank + syn match vimFunctionError "\s\zs[a-z0-9]\i\{-}\ze\s*(" contained contains=vimFuncKey,vimFuncBlank syn match vimFunctionError "\s\zs\%(<[sS][iI][dD]>\|[sSgGbBwWtTlL]:\)\d\i\{-}\ze\s*(" contained contains=vimFuncKey,vimFuncBlank syn match vimElseIfErr "\" syn match vimBufnrWarn /\ Date: Sun, 10 Nov 2024 09:06:37 +0800 Subject: [PATCH 4/4] vim-patch:bbe5252: runtime(vim): Update base-syntax, improve :normal highlighting Fix command name termination, match bang, and allow a line-continued argument. closes: vim/vim#15358 https://github.com/vim/vim/commit/bbe5252c2c2a6a49c794719a894ab10cdafebc62 Co-authored-by: Doug Kearns --- runtime/syntax/vim.vim | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/runtime/syntax/vim.vim b/runtime/syntax/vim.vim index 602e22b258..3ad04e2957 100644 --- a/runtime/syntax/vim.vim +++ b/runtime/syntax/vim.vim @@ -195,7 +195,7 @@ syn match vimNumber '\%(^\|\A\)\zs#\x\{6}' skipwhite nextgroup=vimGlobal,vimSub syn case match " All vimCommands are contained by vimIsCommand. {{{2 -syn cluster vimCmdList contains=vimAbb,vimAddress,vimAutoCmd,vimAugroup,vimBehave,vimCall,vimCatch,vimConst,vimDef,vimDefFold,vimDelcommand,@vimEcho,vimEnddef,vimEndfunction,vimExecute,vimIsCommand,vimExtCmd,vimFor,vimFunction,vimFuncFold,vimGlobal,vimHighlight,vimLet,vimLoadkeymap,vimMap,vimMark,vimMatch,vimNotFunc,vimNorm,vimSet,vimSleep,vimSyntax,vimThrow,vimUnlet,vimUnmap,vimUserCmd,vimMenu,vimMenutranslate,@vim9CmdList +syn cluster vimCmdList contains=vimAbb,vimAddress,vimAutoCmd,vimAugroup,vimBehave,vimCall,vimCatch,vimConst,vimDef,vimDefFold,vimDelcommand,@vimEcho,vimEnddef,vimEndfunction,vimExecute,vimIsCommand,vimExtCmd,vimFor,vimFunction,vimFuncFold,vimGlobal,vimHighlight,vimLet,vimLoadkeymap,vimMap,vimMark,vimMatch,vimNotFunc,vimNormal,vimSet,vimSleep,vimSyntax,vimThrow,vimUnlet,vimUnmap,vimUserCmd,vimMenu,vimMenutranslate,@vim9CmdList syn cluster vim9CmdList contains=vim9Class,vim9Const,vim9Enum,vim9Export,vim9Final,vim9For,vim9Interface,vim9Type,vim9Var syn match vimCmdSep "[:|]\+" skipwhite nextgroup=@vimCmdList,vimSubst1 syn match vimIsCommand "\<\%(\h\w*\|[23]mat\%[ch]\)\>" contains=vimCommand @@ -207,6 +207,7 @@ syn match vimVar "\s\zs&t_\S[a-zA-Z0-9]\>" syn match vimVar "\s\zs&t_k;" syn match vimFBVar contained "\<[bwglstav]:\h[a-zA-Z0-9#_]*\>" syn keyword vimCommand contained in +syn match vimBang contained "!" syn cluster vimExprList contains=vimEnvvar,vimFunc,vimNumber,vimOper,vimOperParen,vimLetRegister,vimString,vimVar,@vim9ExprList syn cluster vim9ExprList contains=vim9Boolean,vim9Null @@ -812,10 +813,10 @@ syn keyword vimMatchNone contained none syn case match syn region vimMatchPattern contained matchgroup=Delimiter start="\z([!#$%&'()*+,-./:;<=>?@[\]^_`{}~]\)" skip="\\\\\|\\\z1" end="\z1" contains=@vimSubstList oneline -" Norm: {{{2 -" ==== -syn match vimNorm "\!\=" skipwhite nextgroup=vimNormalArg contains=vimBang +syn region vimNormalArg contained start="\S" skip=+\n\s*\\\|\n\s*["#]\\ + end="$" contains=@vimContinue " Sleep: {{{2 " ===== @@ -1378,7 +1379,7 @@ if !exists("skip_vim_syntax_inits") hi def link vimMenutranslateComment vimComment hi def link vim9MethodName vimFuncName hi def link vimMtchComment vimComment - hi def link vimNorm vimCommand + hi def link vimNormal vimCommand hi def link vimNotation Special hi def link vimNotFunc vimCommand hi def link vimNotPatSep vimString