diff options
author | dkearns <dougkearns@gmail.com> | 2024-02-27 07:10:18 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-26 21:10:18 +0100 |
commit | 2c51e15b66a4be9b5134c495ef546479aaa89ce9 (patch) | |
tree | ad0e6050b27be98ea5434376e01feee710503ac2 /runtime/syntax/generator | |
parent | ff2b79d23956263ab0120623c37e0b4498be01db (diff) |
runtime(vim): Update syntax file, improve :substitute matching (#14093)
- Differentiate between :substitute and substitute(), fixes #13883.
- Match all allowed :substitute delimiters.
- Remove leading context from :substitute matches.
Signed-off-by: Doug Kearns <dougkearns@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Diffstat (limited to 'runtime/syntax/generator')
-rw-r--r-- | runtime/syntax/generator/vim.vim.base | 80 |
1 files changed, 40 insertions, 40 deletions
diff --git a/runtime/syntax/generator/vim.vim.base b/runtime/syntax/generator/vim.vim.base index 99a0488b34..6527fe178f 100644 --- a/runtime/syntax/generator/vim.vim.base +++ b/runtime/syntax/generator/vim.vim.base @@ -157,16 +157,16 @@ endif " Numbers {{{2 " ======= -syn match vimNumber '\<\d\+\%(\.\d\+\%([eE][+-]\=\d\+\)\=\)\=' skipwhite nextgroup=vimGlobal,vimSubst,vimCommand,vimComment,vim9Comment -syn match vimNumber '-\d\+\%(\.\d\+\%([eE][+-]\=\d\+\)\=\)\=' skipwhite nextgroup=vimGlobal,vimSubst,vimCommand,vimComment,vim9Comment -syn match vimNumber '\<0[xX]\x\+' skipwhite nextgroup=vimGlobal,vimSubst,vimCommand,vimComment,vim9Comment -syn match vimNumber '\%(^\|\A\)\zs#\x\{6}' skipwhite nextgroup=vimGlobal,vimSubst,vimCommand,vimComment,vim9Comment -syn match vimNumber '\<0[zZ][a-zA-Z0-9.]\+' skipwhite nextgroup=vimGlobal,vimSubst,vimCommand,vimComment,vim9Comment -syn match vimNumber '0[0-7]\+' skipwhite nextgroup=vimGlobal,vimSubst,vimCommand,vimComment,vim9Comment -syn match vimNumber '0[bB][01]\+' skipwhite nextgroup=vimGlobal,vimSubst,vimCommand,vimComment,vim9Comment +syn match vimNumber '\<\d\+\%(\.\d\+\%([eE][+-]\=\d\+\)\=\)\=' skipwhite nextgroup=vimGlobal,vimSubst1,vimCommand,vimComment,vim9Comment +syn match vimNumber '-\d\+\%(\.\d\+\%([eE][+-]\=\d\+\)\=\)\=' skipwhite nextgroup=vimGlobal,vimSubst1,vimCommand,vimComment,vim9Comment +syn match vimNumber '\<0[xX]\x\+' skipwhite nextgroup=vimGlobal,vimSubst1,vimCommand,vimComment,vim9Comment +syn match vimNumber '\%(^\|\A\)\zs#\x\{6}' skipwhite nextgroup=vimGlobal,vimSubst1,vimCommand,vimComment,vim9Comment +syn match vimNumber '\<0[zZ][a-zA-Z0-9.]\+' skipwhite nextgroup=vimGlobal,vimSubst1,vimCommand,vimComment,vim9Comment +syn match vimNumber '0[0-7]\+' skipwhite nextgroup=vimGlobal,vimSubst1,vimCommand,vimComment,vim9Comment +syn match vimNumber '0[bB][01]\+' skipwhite nextgroup=vimGlobal,vimSubst1,vimCommand,vimComment,vim9Comment " All vimCommands are contained by vimIsCommand. {{{2 -syn match vimCmdSep "[:|]\+" skipwhite nextgroup=vimAbb,vimAddress,vimAutoCmd,vimAugroup,vimBehave,vimEcho,vimEchoHL,vimExecute,vimIsCommand,vimExtCmd,vimFilter,vimGlobal,vimHighlight,vimLet,vimMap,vimMark,vimNorm,vimSet,vimSyntax,vimUnlet,vimUnmap,vimUserCmd +syn match vimCmdSep "[:|]\+" skipwhite nextgroup=vimAbb,vimAddress,vimAutoCmd,vimAugroup,vimBehave,vimEcho,vimEchoHL,vimExecute,vimIsCommand,vimExtCmd,vimFilter,vimGlobal,vimHighlight,vimLet,vimMap,vimMark,vimNorm,vimSet,vimSubst1,vimSyntax,vimUnlet,vimUnmap,vimUserCmd syn match vimIsCommand "\<\%(\h\w*\|[23]mat\%[ch]\)\>" contains=vimCommand syn match vimVar contained "\<\h[a-zA-Z0-9#_]*\>" syn match vimVar "\<[bwglstav]:\h[a-zA-Z0-9#_]*\>" @@ -194,7 +194,6 @@ syn match vimBehave "\<be\%[have]\>" nextgroup=vimBehaveBang,vimBehaveModel,vi syn match vimBehaveBang contained "\a\@1<=!" nextgroup=vimBehaveModel skipwhite syn keyword vimBehaveModel contained mswin xterm -hi def link vimBehaveBang vimBang " Filetypes {{{2 " ========= syn match vimFiletype "\<filet\%[ype]\(\s\+\I\i*\)*" skipwhite contains=vimFTCmd,vimFTOption,vimFTError @@ -270,12 +269,12 @@ syn region vimKeymap matchgroup=vimCommand start="\<loadk\%[eymap]\>" end="\%$" " Special Filenames, Modifiers, Extension Removal: {{{2 " =============================================== -syn match vimSpecFile "<c\(word\|WORD\)>" nextgroup=vimSpecFileMod,vimSubst -syn match vimSpecFile "<\([acs]file\|amatch\|abuf\)>" nextgroup=vimSpecFileMod,vimSubst -syn match vimSpecFile "\s%[ \t:]"ms=s+1,me=e-1 nextgroup=vimSpecFileMod,vimSubst -syn match vimSpecFile "\s%$"ms=s+1 nextgroup=vimSpecFileMod,vimSubst -syn match vimSpecFile "\s%<"ms=s+1,me=e-1 nextgroup=vimSpecFileMod,vimSubst -syn match vimSpecFile "#\d\+\|[#%]<\>" nextgroup=vimSpecFileMod,vimSubst +syn match vimSpecFile "<c\(word\|WORD\)>" nextgroup=vimSpecFileMod,vimSubst1 +syn match vimSpecFile "<\([acs]file\|amatch\|abuf\)>" nextgroup=vimSpecFileMod,vimSubst1 +syn match vimSpecFile "\s%[ \t:]"ms=s+1,me=e-1 nextgroup=vimSpecFileMod,vimSubst1 +syn match vimSpecFile "\s%$"ms=s+1 nextgroup=vimSpecFileMod,vimSubst1 +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 " User-Specified Commands: {{{2 @@ -356,33 +355,34 @@ syn match vimStringInterpolationBrace "}}" syn cluster vimSubstList contains=vimPatSep,vimPatRegion,vimPatSepErr,vimSubstTwoBS,vimSubstRange,vimNotation syn cluster vimSubstRepList contains=vimSubstSubstr,vimSubstTwoBS,vimNotation syn cluster vimSubstList add=vimCollection -syn match vimSubst "\(:\+\s*\|^\s*\||\s*\)\<\%(\<s\%[ubstitute]\>\|\<sm\%[agic]\>\|\<sno\%[magic]\>\)[:#[:alpha:]]\@!" nextgroup=vimSubstPat -"syn match vimSubst "\%(^\|[^\\]\)\<s\%[ubstitute]\>[:#[:alpha:]]\@!" nextgroup=vimSubstPat contained -syn match vimSubst "\%(^\|[^\\\"']\)\<s\%[ubstitute]\>[:#[:alpha:]\"']\@!" nextgroup=vimSubstPat contained -syn match vimSubst "/\zs\<s\%[ubstitute]\>\ze/" nextgroup=vimSubstPat -syn match vimSubst "\(:\+\s*\|^\s*\)s\ze#.\{-}#.\{-}#" nextgroup=vimSubstPat -syn match vimSubst1 contained "\<s\%[ubstitute]\>" nextgroup=vimSubstPat -syn match vimSubst2 contained "s\%[ubstitute]\>" nextgroup=vimSubstPat -syn region vimSubstPat contained matchgroup=vimSubstDelim start="\z([^a-zA-Z( \t[\]&]\)"rs=s+1 skip="\\\\\|\\\z1" end="\z1"re=e-1,me=e-1 contains=@vimSubstList nextgroup=vimSubstRep4 oneline -syn region vimSubstRep4 contained matchgroup=vimSubstDelim start="\z(.\)" skip="\\\\\|\\\z1" end="\z1" matchgroup=vimNotation end="<[cC][rR]>" contains=@vimSubstRepList nextgroup=vimSubstFlagErr oneline -syn region vimCollection contained transparent start="\\\@<!\[" skip="\\\[" end="\]" contains=vimCollClass -syn match vimCollClassErr contained "\[:.\{-\}:\]" -syn match vimCollClass contained transparent "\%#=1\[:\(alnum\|alpha\|blank\|cntrl\|digit\|graph\|lower\|print\|punct\|space\|upper\|xdigit\|retu\%[rn]\|tab\|escape\|backspace\):\]" -syn match vimSubstSubstr contained "\\z\=\d" -syn match vimSubstTwoBS contained "\\\\" -syn match vimSubstFlagErr contained "[^< \t\r|]\+" contains=vimSubstFlags -syn match vimSubstFlags contained "[&cegiIlnpr#]\+" +syn match vimSubst "^\s*\%(s\%[ubstitute]\|sm\%[agic]\|sno\%[magic]\)\>[\"#|]\@!" nextgroup=vimSubstPat +syn match vimSubst "^\s*\%(s\%[ubstitute]\|sm\%[agic]\|sno\%[magic]\)_\@=" nextgroup=vimSubstPat +syn match vimSubst "^\s*\%(s\%[ubstitute]\|sm\%[agic]\>\|sno\%[magic]\)\ze#.\{-}#.\{-}#" nextgroup=vimSubstPat +syn match vimSubst1 contained "\%(s\%[ubstitute]\|sm\%[agic]\>\|sno\%[magic]\)\>[\"#|]\@!" nextgroup=vimSubstPat +syn match vimSubst1 contained "\%(s\%[ubstitute]\|sm\%[agic]\>\|sno\%[magic]\)_\@=" nextgroup=vimSubstPat +syn match vimSubst1 contained "\%(s\%[ubstitute]\|sm\%[agic]\>\|sno\%[magic]\)\ze#.\{-}#.\{-}#" nextgroup=vimSubstPat +" TODO: Vim9 illegal separators for abbreviated :s form are [-.:], :su\%[...] required +" : # is allowed but "not recommended" (see :h pattern-delimiter) +syn region vimSubstPat contained matchgroup=vimSubstDelim start="\z([!#$%&'()*+,-./:;<=>?@[\]^_`{}~]\)"rs=s+1 skip="\\\\\|\\\z1" end="\z1"re=e-1,me=e-1 contains=@vimSubstList nextgroup=vimSubstRep4 oneline +syn region vimSubstRep4 contained matchgroup=vimSubstDelim start="\z(.\)" skip="\\\\\|\\\z1" end="\z1" matchgroup=vimNotation end="<[cC][rR]>" contains=@vimSubstRepList nextgroup=vimSubstFlagErr oneline +syn region vimCollection contained transparent start="\\\@<!\[" skip="\\\[" end="\]" contains=vimCollClass +syn match vimCollClassErr contained "\[:.\{-\}:\]" +syn match vimCollClass contained transparent "\%#=1\[:\(alnum\|alpha\|blank\|cntrl\|digit\|graph\|lower\|print\|punct\|space\|upper\|xdigit\|retu\%[rn]\|tab\|escape\|backspace\):\]" +syn match vimSubstSubstr contained "\\z\=\d" +syn match vimSubstTwoBS contained "\\\\" +syn match vimSubstFlagErr contained "[^< \t\r|]\+" contains=vimSubstFlags +syn match vimSubstFlags contained "[&cegiIlnpr#]\+" " 'String': {{{2 syn match vimString "[^(,]'[^']\{-}\zs'" " Marks, Registers, Addresses, Filters: {{{2 -syn match vimMark "'[a-zA-Z0-9]\ze[-+,!]" nextgroup=vimFilter,vimMarkNumber,vimSubst -syn match vimMark "'[<>]\ze[-+,!]" nextgroup=vimFilter,vimMarkNumber,vimSubst -syn match vimMark ",\zs'[<>]\ze" nextgroup=vimFilter,vimMarkNumber,vimSubst -syn match vimMark "[!,:]\zs'[a-zA-Z0-9]" nextgroup=vimFilter,vimMarkNumber,vimSubst -syn match vimMark "\<norm\%[al]\s\zs'[a-zA-Z0-9]" nextgroup=vimFilter,vimMarkNumber,vimSubst -syn match vimMarkNumber "[-+]\d\+" contained contains=vimOper nextgroup=vimSubst2 +syn match vimMark "'[a-zA-Z0-9]\ze[-+,!]" nextgroup=vimFilter,vimMarkNumber,vimSubst1 +syn match vimMark "'[<>]\ze[-+,!]" nextgroup=vimFilter,vimMarkNumber,vimSubst1 +syn match vimMark ",\zs'[<>]\ze" nextgroup=vimFilter,vimMarkNumber,vimSubst1 +syn match vimMark "[!,:]\zs'[a-zA-Z0-9]" nextgroup=vimFilter,vimMarkNumber,vimSubst1 +syn match vimMark "\<norm\%[al]\s\zs'[a-zA-Z0-9]" nextgroup=vimFilter,vimMarkNumber,vimSubst1 +syn match vimMarkNumber "[-+]\d\+" contained contains=vimOper nextgroup=vimSubst1 syn match vimPlainMark contained "'[a-zA-Z0-9]" syn match vimRange "[`'][a-zA-Z0-9],[`'][a-zA-Z0-9]" contains=vimMark skipwhite nextgroup=vimFilter @@ -713,8 +713,8 @@ syn match vimCommentTitleLeader '"\s\+'ms=s+1 contained " ==================== syn match vimSearch '^\s*[/?].*' contains=vimSearchDelim syn match vimSearchDelim '^\s*\zs[/?]\|[/?]$' contained -syn region vimGlobal matchgroup=Statement start='\<g\%[lobal]!\=/' skip='\\.' end='/' skipwhite nextgroup=vimSubst -syn region vimGlobal matchgroup=Statement start='\<v\%[global]!\=/' skip='\\.' end='/' skipwhite nextgroup=vimSubst +syn region vimGlobal matchgroup=Statement start='\<g\%[lobal]!\=/' skip='\\.' end='/' skipwhite nextgroup=vimSubst1 +syn region vimGlobal matchgroup=Statement start='\<v\%[global]!\=/' skip='\\.' end='/' skipwhite nextgroup=vimSubst1 " Embedded Scripts: {{{2 " ================ @@ -934,7 +934,7 @@ if !exists("skip_vim_syntax_inits") hi def link vimAutoCmdMod Special hi def link vimAutoSet vimCommand hi def link vimBang vimOper - hi def link vimBehaveBang vimBang + hi def link vimBehaveBang vimBang hi def link vimBehaveModel vimBehave hi def link vimBehave vimCommand hi def link vimBracket Delimiter |