0
0
mirror of https://github.com/vim/vim.git synced 2025-11-16 23:24:03 -05:00

runtime(vim): Update base syntax and generator, match :cd commands

Match :cd commands explicitly.

fixes: #17964
closes: #18736

Reported by Maxim Kim.

Signed-off-by: Doug Kearns <dougkearns@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Doug Kearns
2025-11-15 10:17:17 +00:00
committed by Christian Brabandt
parent de7049ede1
commit f46616f0c4
16 changed files with 317 additions and 19 deletions

View File

@@ -1,7 +1,7 @@
" Vim syntax file generator
" Language: Vim script
" Maintainer: Hirohito Higashi (h_east)
" Last Change: 2025 Nov 11
" Last Change: 2025 Nov 13
let s:keepcpo= &cpo
set cpo&vim
@@ -288,6 +288,7 @@ function s:get_vim_command_type(cmd_name)
" 6: unmap
" 7: abclear
" 8: modifiers
" 9: cd
" 99: (Exclude registration of "syn keyword")
let ab_prefix = '^[ci]\?'
let menu_prefix = '^\%([acinostvx]\?\|tl\)'
@@ -459,6 +460,9 @@ function s:get_vim_command_type(cmd_name)
let ret = 6
elseif index(s:get_cmd_modifiers(), a:cmd_name) != -1
let ret = 8
" :chdir handled specially for command/function distinction
elseif a:cmd_name =~# '^\%([lt]\?cd\|[lt]chdir\)$'
let ret = 9
else
let ret = 0
endif
@@ -926,6 +930,9 @@ function s:update_syntax_vim_file(vim_info)
" vimCommand - modifier
let lnum = s:search_and_check(kword . ' modifier', base_fname, str_info)
let lnum = s:append_syn_vimcmd(lnum, str_info, li, 8)
" vimCommand - cd
let lnum = s:search_and_check(kword . ' cd', base_fname, str_info)
let lnum = s:append_syn_vimcmd(lnum, str_info, li, 9)
update
quit!

View File

@@ -2,7 +2,7 @@
" Language: Vim script
" Maintainer: Hirohito Higashi <h.east.727 ATMARK gmail.com>
" Doug Kearns <dougkearns@gmail.com>
" Last Change: 2025 Nov 11
" Last Change: 2025 Nov 13
" Former Maintainer: Charles E. Campbell
" DO NOT CHANGE DIRECTLY.
@@ -36,7 +36,7 @@ syn cluster vimCommentGroup contains=vimTodo,@Spell
" GEN_SYN_VIM: vimCommand normal, START_STR='syn keyword vimCommand contained', END_STR='nextgroup=vimBang'
" Lower priority :syn-match to allow for :command/function() distinction
syn match vimCommand "\<chd\%[ir]\>" nextgroup=vimBang
" :chdir is handled specially elsewhere
syn match vimCommand "\<co\%[py]\>" nextgroup=vimBang
syn match vimCommand "\<d\%[elete]\>" nextgroup=vimBang
syn match vimCommand "\<j\%[oin]\>" nextgroup=vimBang
@@ -246,7 +246,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=@vimCmdList,vimSubst1,@vimFunc
syn match vimCmdSep ":\+" skipwhite nextgroup=@vimCmdList,vimSubst1
@@ -311,6 +311,20 @@ syn keyword vimBehaveModel contained mswin xterm
" ====
syn match vimCall "\<call\=\>" 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 match vimCd "\<chd\%[ir]\>" skipwhite nextgroup=vimCdBang,vimCdArg,vimComment,vim9Comment,vimCmdSep
syn region vimCdArg contained
\ start=+["#|]\@!\S+
\ end="\ze\s*$"
\ end=+\ze\s*\\\@1<!["#|]+
\ skipwhite nextgroup=vimComment,vim9Comment,vimCmdSep
\ contains=vimSpecfile,@vimWildCard
\ oneline
syn match vimCdBang contained "\a\@1<=!" skipwhite nextgroup=vimCdArg,vimComment,vim9Comment,vimCmdSep
" Debuggreedy {{{2
" ===========
" TODO: special-cased until generalised range/count support is implemented
@@ -825,6 +839,10 @@ syn match vimSpecFile "\s%<"ms=s+1,me=e-1 nextgroup=vimSpecFileMod,vimSubst1
syn match vimSpecFile "#\d\+\|[#%]<\>" 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
@@ -2370,6 +2388,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