vim-patch:61887b3d6fd8

runtime(vim): Update base-syntax, improve :echo and :execute highlighting (vim/vim#14199)

Improve :echo and :execute highlighting.

- Add better line-continuation support for both commands.
- Improve the :execute command's expression argument matching.
- Remove the fix for issue vim/vim#9987 as this is now handled by correctly
  matching the parens in :echo (...) as operator parens.

61887b3d6f

Co-authored-by: dkearns <dougkearns@gmail.com>
This commit is contained in:
zeertzjq
2024-03-15 21:46:38 +08:00
parent b7779c5146
commit b958b5ee4f

View File

@@ -155,7 +155,7 @@ syn match vimNumber '\%(^\|\A\)\zs#\x\{6}' skipwhite nextgroup=vimGlobal,vimSub
syn case match syn case match
" All vimCommands are contained by vimIsCommand. {{{2 " All vimCommands are contained by vimIsCommand. {{{2
syn cluster vimCmdList contains=vimAbb,vimAddress,vimAutoCmd,vimAugroup,vimBehave,vimEcho,vimEchoHL,vimExecute,vimIsCommand,vimExtCmd,vimFunction,vimGlobal,vimHighlight,vimLet,vimMap,vimMark,vimNotFunc,vimNorm,vimSet,vimSyntax,vimUnlet,vimUnmap,vimUserCmd,vimMenu,vimMenutranslate syn cluster vimCmdList contains=vimAbb,vimAddress,vimAutoCmd,vimAugroup,vimBehave,@vimEcho,vimExecute,vimIsCommand,vimExtCmd,vimFunction,vimGlobal,vimHighlight,vimLet,vimMap,vimMark,vimNotFunc,vimNorm,vimSet,vimSyntax,vimUnlet,vimUnmap,vimUserCmd,vimMenu,vimMenutranslate
syn match vimCmdSep "[:|]\+" skipwhite nextgroup=@vimCmdList,vimSubst1 syn match vimCmdSep "[:|]\+" skipwhite nextgroup=@vimCmdList,vimSubst1
syn match vimIsCommand "\<\%(\h\w*\|[23]mat\%[ch]\)\>" contains=vimCommand syn match vimIsCommand "\<\%(\h\w*\|[23]mat\%[ch]\)\>" contains=vimCommand
syn match vimVar contained "\<\h[a-zA-Z0-9#_]*\>" syn match vimVar contained "\<\h[a-zA-Z0-9#_]*\>"
@@ -436,16 +436,27 @@ syn match vimAutoCmdMod "\(++\)\=\(once\|nested\)"
" Echo And Execute: -- prefer strings! {{{2 " Echo And Execute: -- prefer strings! {{{2
" ================ " ================
" GEN_SYN_VIM: vimCommand echo, START_STR='syn keyword vimEcho', END_STR='skipwhite nextgroup=vimEchoExpr' " NOTE: No trailing comments
syn keyword vimEcho ec[ho] echoe[rr] echom[sg] echoc[onsole] echon echow[indow] skipwhite nextgroup=vimEchoExpr
syn region vimEchoExpr contained start="[^[:space:]|]" skip=+\\\\\|\\|\|\n\s*\\\|\n\s*"\\ + matchgroup=vimCmdSep end="|" end="$" contains=@vimContinue,@vimExprList
syn match vimEchoHL "\<echohl\=\>" skipwhite nextgroup=vimGroup,vimHLGroup,vimEchoHLNone,vimOnlyHLGroup,nvimHLGroup syn region vimEcho
\ matchgroup=vimCommand
\ start="\<ec\%[ho]\>"
\ start="\<echoe\%[rr]\>"
\ start="\<echom\%[sg]\>"
\ start="\<echoc\%[onsole]\>"
\ start="\<echon\>"
\ start="\<echow\%[indow]\>"
\ skip=+\\|\|\n\s*\\\|\n\s*"\\ +
\ matchgroup=vimCmdSep end="|" excludenl end="$" contains=@vimContinue,@vimExprList transparent
syn match vimEchohl "\<echohl\=\>" skipwhite nextgroup=vimGroup,vimHLGroup,vimEchohlNone,vimOnlyHLGroup,nvimHLGroup
syn case ignore syn case ignore
syn keyword vimEchoHLNone none syn keyword vimEchohlNone contained none
syn case match syn case match
syn region vimExecute oneline excludenl matchgroup=vimCommand start="\<exe\%[cute]\>" skip="\(\\\\\)*\\|" end="$\||\|<[cC][rR]>" contains=vimFuncVar,vimIsCommand,vimOper,vimNotation,vimOperParen,vimString,vimVar syn cluster vimEcho contains=vimEcho.*
syn region vimExecute matchgroup=vimCommand start="\<exe\%[cute]\>" skip=+\\|\|\n\s*\\\|\n\s*"\\ + matchgroup=vimCmdSep end="|" excludenl end="$" contains=@vimContinue,@vimExprList transparent
" Maps: {{{2 " Maps: {{{2
" ==== " ====
@@ -520,9 +531,8 @@ syn case match
" User Function Highlighting: {{{2 " User Function Highlighting: {{{2
" (following Gautam Iyer's suggestion) " (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 vimFunc "\%(\%([sSgGbBwWtTlL]:\|<[sS][iI][dD]>\)\=\%(\w\+\.\)*\I[a-zA-Z0-9_.]*\)\ze\s*(" contains=vimFuncName,vimUserFunc,vimExecute
syn match vimUserFunc contained "\%(\%([sSgGbBwWtTlL]:\|<[sS][iI][dD]>\)\=\%(\w\+\.\)*\I[a-zA-Z0-9_.]*\)\|\<\u[a-zA-Z0-9.]*\>\|\<if\>" contains=vimNotation syn match vimUserFunc contained "\%(\%([sSgGbBwWtTlL]:\|<[sS][iI][dD]>\)\=\%(\w\+\.\)*\I[a-zA-Z0-9_.]*\)\|\<\u[a-zA-Z0-9.]*\>\|\<if\>" contains=vimNotation
syn keyword vimFuncEcho contained ec ech echo
" User Command Highlighting: {{{2 " User Command Highlighting: {{{2
syn match vimUsrCmd '^\s*\zs\u\%(\w*\)\@>\%([(#[]\|\s\+\%([-+*/%]\=\|\.\.\)=\)\@!' syn match vimUsrCmd '^\s*\zs\u\%(\w*\)\@>\%([(#[]\|\s\+\%([-+*/%]\=\|\.\.\)=\)\@!'
@@ -965,8 +975,8 @@ if !exists("skip_vim_syntax_inits")
hi def link vimContinueComment vimComment hi def link vimContinueComment vimComment
hi def link vimCtrlChar SpecialChar hi def link vimCtrlChar SpecialChar
hi def link vimEcho vimCommand hi def link vimEcho vimCommand
hi def link vimEchoHLNone vimGroup hi def link vimEchohlNone vimGroup
hi def link vimEchoHL vimCommand hi def link vimEchohl vimCommand
hi def link vimElseIfErr Error hi def link vimElseIfErr Error
hi def link vimElseif vimCondHL hi def link vimElseif vimCondHL
hi def link vimEnvvar PreProc hi def link vimEnvvar PreProc