From d1c5c11ee0c30f08bad302157924e68f8b685fea Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 15 Nov 2025 18:27:06 +0800 Subject: [PATCH] vim-patch:f46616f: runtime(vim): Update base syntax and generator, match :cd commands Match :cd commands explicitly. fixes: vim/vim#17964 closes: vim/vim#18736 Reported by Maxim Kim. https://github.com/vim/vim/commit/f46616f0c4b7254cfe2153c845f33c347ef67446 Co-authored-by: Doug Kearns --- runtime/syntax/vim.vim | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/runtime/syntax/vim.vim b/runtime/syntax/vim.vim index 7fb7201747..c53d1e1d0a 100644 --- a/runtime/syntax/vim.vim +++ b/runtime/syntax/vim.vim @@ -31,7 +31,7 @@ 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 +" :chdir is handled specially elsewhere syn match vimCommand "\" nextgroup=vimBang syn match vimCommand "\" nextgroup=vimBang syn match vimCommand "\" nextgroup=vimBang @@ -232,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,vimAt,vimAutocmd,vimAugroup,vimBehave,vimCall,vimCatch,vimCommandModifier,vimConst,vimDoautocmd,vimDebuggreedy,vimDef,vimDefFold,vimDefer,vimDelcommand,vimDelFunction,vimDoCommand,@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,vimPrompt,vimRedir,vimSet,vimSleep,vimSort,vimSyntax,vimSyntime,vimSynColor,vimSynLink,vimTerminal,vimThrow,vimUniq,vimUnlet,vimUnlockvar,vimUnmap,vimUserCmd,vimVimgrep,vimVimgrepadd,vimWincmd,vimMenu,vimMenutranslate,@vim9CmdList,@vimExUserCmdList,vimLua,vimMzScheme,vimPerl,vimPython,vimPython3,vimPythonX,vimRuby,vimTcl +syn cluster vimCmdList contains=vimAbb,vimAddress,vimAt,vimAutocmd,vimAugroup,vimBehave,vimCall,vimCatch,vimCd,vimCommandModifier,vimConst,vimDoautocmd,vimDebuggreedy,vimDef,vimDefFold,vimDefer,vimDelcommand,vimDelFunction,vimDoCommand,@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,vimPrompt,vimRedir,vimSet,vimSleep,vimSort,vimSyntax,vimSyntime,vimSynColor,vimSynLink,vimTerminal,vimThrow,vimUniq,vimUnlet,vimUnlockvar,vimUnmap,vimUserCmd,vimVimgrep,vimVimgrepadd,vimWincmd,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" skipwhite nextgroup=vimVar,@vimFunc +" Cd: {{{2 +" == +" GEN_SYN_VIM: vimCommand cd, START_STR='syn keyword vimCd', END_STR='skipwhite nextgroup=vimCdBang,vimCdArg,vimComment,vim9Comment,vimCmdSep' +syn keyword vimCd cd lc[d] lch[dir] tc[d] tch[dir] skipwhite nextgroup=vimCdBang,vimCdArg,vimComment,vim9Comment,vimCmdSep +syn match vimCd "\" skipwhite nextgroup=vimCdBang,vimCdArg,vimComment,vim9Comment,vimCmdSep +syn region vimCdArg contained + \ start=+["#|]\@!\S+ + \ end="\ze\s*$" + \ end=+\ze\s*\\\@1" nextgroup=vimSpecFileMod,vimSubst1 syn match vimSpecFileMod "\(:[phtre]\)\+" contained +syn match vimSpecFile contained "%[ \t:]"me=e-1 nextgroup=vimSpecFileMod +syn match vimSpecFile contained excludenl "%$" nextgroup=vimSpecFileMod +syn match vimSpecFile contained "%<"me=e-1 nextgroup=vimSpecFileMod + " User-Specified Commands: {{{2 " ======================= syn cluster vimUserCmdList contains=@vimCmdList,vimCmplxRepeat,@vimComment,vimCtrlChar,vimEscapeBrace,@vimFunc,vimNotation,vimNumber,vimOper,vimRegister,vimSpecFile,vimString,vimSubst,vimSubstRep,vimSubstRange @@ -2367,6 +2386,8 @@ if !exists("skip_vim_syntax_inits") hi def link vimBracket Delimiter hi def link vimCall vimCommand hi def link vimCatch vimCommand + hi def link vimCd vimCommand + hi def link vimCdBang vimBang hi def link vimCmplxRepeat SpecialChar hi def link vimCommand Statement hi def link vimCommandModifier vimCommand