From 10a0c59487247c0e2fb07cfdd00f5d9aa8a5c7af Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 19 Jul 2025 06:01:25 +0800 Subject: [PATCH] vim-patch:2f7c957: runtime(vim): Update base syntax and generator, improve command/function distinction - Match Ex command modifiers and functions with the same name correctly. E.g., :browse and browse(). - Match full :eval command. closes: vim/vim#17789 https://github.com/vim/vim/commit/2f7c957c8d89b0fe06896ee0e2eaa1c3c0b2b485 Co-authored-by: Doug Kearns --- runtime/syntax/vim.vim | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/runtime/syntax/vim.vim b/runtime/syntax/vim.vim index b1347f760c..1b6a066334 100644 --- a/runtime/syntax/vim.vim +++ b/runtime/syntax/vim.vim @@ -30,15 +30,27 @@ endfunction syn keyword vimTodo contained COMBAK FIXME TODO XXX syn cluster vimCommentGroup contains=vimTodo,@Spell +" Lower priority :syn-match to allow for :command/function() distinction +syn match vimCommand "\" nextgroup=vimBang +syn match vimCommand "\" nextgroup=vimBang +syn match vimCommand "\" nextgroup=vimBang +syn match vimCommand "\" nextgroup=vimBang +syn match vimCommand "\" nextgroup=vimBang +syn match vimCommand "\" nextgroup=vimBang + " GEN_SYN_VIM: vimCommand modifier, START_STR='syn keyword vimCommandModifier', END_STR='skipwhite nextgroup=vimCommandModifierBang,@vimCmdList' -syn keyword vimCommandModifier abo[veleft] bel[owright] bo[tright] bro[wse] conf[irm] hid[e] hor[izontal] kee[pmarks] keepj[umps] keepp[atterns] keepa[lt] lefta[bove] leg[acy] loc[kmarks] noa[utocmd] nos[wapfile] rightb[elow] san[dbox] sil[ent] tab to[pleft] uns[ilent] verb[ose] vert[ical] vim9[cmd] skipwhite nextgroup=vimCommandModifierBang,@vimCmdList +syn keyword vimCommandModifier abo[veleft] bel[owright] bo[tright] hid[e] hor[izontal] kee[pmarks] keepj[umps] keepp[atterns] keepa[lt] lefta[bove] leg[acy] loc[kmarks] noa[utocmd] nos[wapfile] rightb[elow] san[dbox] sil[ent] tab to[pleft] uns[ilent] verb[ose] vert[ical] vim9[cmd] skipwhite nextgroup=vimCommandModifierBang,@vimCmdList " :filter is handled specially elsewhere syn match vimCommandModifierBang contained "\a\@1<=!" skipwhite nextgroup=@vimCmdList +" Lower priority :syn-match to allow for :command/function() distinction +syn match vimCommand "\" skipwhite nextgroup=vimCommandModifierBang,@vimCmdList +syn match vimCommand "\" skipwhite nextgroup=vimCommandModifierBang,@vimCmdList + " Special and plugin vim commands {{{2 syn match vimCommand contained "\" syn keyword vimOnlyCommand contained fix[del] op[en] sh[ell] P[rint] -syn keyword vimStdPlugin contained Arguments Asm Break Cfilter Clear Continue DiffOrig Evaluate Finish Gdb Lfilter Man Over Program Run S Source Step Stop Termdebug TermdebugCommand TOhtml Until Winbar XMLent XMLns +syn keyword vimStdPlugin contained Arguments Asm Break Cfilter Clear Continue DiffOrig Evaluate Finish Gdb Lfilter Man Over Program Run S Source Step Stop Termdebug TermdebugCommand TOhtml Until Winbar XMLent XMLns " Vim-specific options {{{2 syn keyword vimOnlyOption contained biosk bioskey cp compatible consk conskey cm cryptmethod edcompatible guipty key macatsui mzq mzquantum osfiletype oft renderoptions rop st shelltype sn shortname tenc termencoding ta textauto tx textmode tf ttyfast ttym ttymouse tbi ttybuiltin wiv weirdinvert @@ -220,7 +232,7 @@ syn match vimNumber '\<0z\%(\x\x\)\+\%(\.\%(\x\x\)\+\)*' skipwhite nextgroup=@vi syn case match " All vimCommands are contained by vimIsCommand. {{{2 -syn cluster vimCmdList contains=vimAbb,vimAddress,vimAutocmd,vimAugroup,vimBehave,vimCall,vimCatch,vimCommandModifier,vimConst,vimDoautocmd,vimDebuggreedy,vimDef,vimDefFold,vimDelcommand,vimDelFunction,@vimEcho,vimElse,vimEnddef,vimEndfunction,vimEndif,vimExecute,vimIsCommand,vimExtCmd,vimExFilter,vimExMark,vimFiletype,vimFor,vimFunction,vimFunctionFold,vimGrep,vimGrepAdd,vimGlobal,vimHelpgrep,vimHighlight,vimImport,vimLet,vimLoadkeymap,vimLockvar,vimMake,vimMap,vimMark,vimMatch,vimNotFunc,vimNormal,vimProfdel,vimProfile,vimRedir,vimSet,vimSleep,vimSort,vimSyntax,vimSynColor,vimSynLink,vimThrow,vimUniq,vimUnlet,vimUnlockvar,vimUnmap,vimUserCmd,vimVimgrep,vimVimgrepadd,vimMenu,vimMenutranslate,@vim9CmdList,@vimExUserCmdList,vimLua,vimMzScheme,vimPerl,vimPython,vimPython3,vimPythonX,vimRuby,vimTcl +syn cluster vimCmdList contains=vimAbb,vimAddress,vimAutocmd,vimAugroup,vimBehave,vimCall,vimCatch,vimCommandModifier,vimConst,vimDoautocmd,vimDebuggreedy,vimDef,vimDefFold,vimDelcommand,vimDelFunction,@vimEcho,vimElse,vimEnddef,vimEndfunction,vimEndif,vimEval,vimExecute,vimIsCommand,vimExtCmd,vimExFilter,vimExMark,vimFiletype,vimFor,vimFunction,vimFunctionFold,vimGrep,vimGrepAdd,vimGlobal,vimHelpgrep,vimHighlight,vimImport,vimLet,vimLoadkeymap,vimLockvar,vimMake,vimMap,vimMark,vimMatch,vimNotFunc,vimNormal,vimProfdel,vimProfile,vimRedir,vimSet,vimSleep,vimSort,vimSyntax,vimSynColor,vimSynLink,vimThrow,vimUniq,vimUnlet,vimUnlockvar,vimUnmap,vimUserCmd,vimVimgrep,vimVimgrepadd,vimMenu,vimMenutranslate,@vim9CmdList,@vimExUserCmdList,vimLua,vimMzScheme,vimPerl,vimPython,vimPython3,vimPythonX,vimRuby,vimTcl syn cluster vim9CmdList contains=vim9Abstract,vim9Class,vim9Const,vim9Enum,vim9Export,vim9Final,vim9For,vim9Interface,vim9Type,vim9Var syn match vimCmdSep "\\\@1" + \ skip=+\\|\|||\|\n\s*\%(\\\|["#]\\ \)+ + \ end="\ze|" + \ excludenl end="$" + \ nextgroup=vimCmdSep + \ contains=@vimContinue,@vimExprList + \ transparent + " Filter: {{{2 " ====== syn match vimExFilter "\" skipwhite nextgroup=vimExFilterBang,vimExFilterPattern @@ -2068,7 +2090,7 @@ unlet s:interfaces " (following Gautam Iyer's suggestion) " ========================== syn match vimFunc contained "\<\l\w*\ze\s*(" skipwhite nextgroup=vimOperParen contains=vimFuncName -syn match vimUserFunc contained "\.\@1<=\l\w*\ze\s*(" skipwhite nextgroup=vimOperParen contains=vimFuncName +syn match vimUserFunc contained "\.\@1<=\l\w*\ze\s*(" skipwhite nextgroup=vimOperParen syn match vimUserFunc contained "\<\%([[:upper:]_]\|\%(\h\w*\.\)\+\h\)\w*\ze\s*(" skipwhite nextgroup=vimOperParen contains=vim9MethodName,vim9Super,vim9This syn match vimUserFunc contained "\<\%(g:\)\=\%(\h\w*#\)\+\h\w*\ze\s*(" skipwhite nextgroup=vimOperParen contains=vimVarScope syn match vimUserFunc contained "\%(\<[sgbwtlav]:\|<[sS][iI][dD]>\)\%(\h\w*\.\)*\h\w*\ze\s*(" skipwhite nextgroup=vimOperParen contains=vimVarScope,vimNotation @@ -2225,6 +2247,7 @@ if !exists("skip_vim_syntax_inits") hi def link vimEnvvar PreProc hi def link vimError Error hi def link vimEscape Special + hi def link vimEval vimCommand hi def link vimExFilter vimCommand hi def link vimExFilterBang vimBang hi def link vimExMark vimCommand