diff options
author | zeertzjq <zeertzjq@outlook.com> | 2024-03-15 21:46:38 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2024-03-15 21:49:17 +0800 |
commit | b958b5ee4f1eb3ce7ebae8222132e201f855e1ce (patch) | |
tree | 42e79d565ad47593058161f5aab83664ca7d14fe | |
parent | b7779c514632f8c7f791c92203a96d43fffa57c6 (diff) | |
download | rneovim-b958b5ee4f1eb3ce7ebae8222132e201f855e1ce.tar.gz rneovim-b958b5ee4f1eb3ce7ebae8222132e201f855e1ce.tar.bz2 rneovim-b958b5ee4f1eb3ce7ebae8222132e201f855e1ce.zip |
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.
https://github.com/vim/vim/commit/61887b3d6fd8b441c90416ea7855e1fe5a9ae32c
Co-authored-by: dkearns <dougkearns@gmail.com>
-rw-r--r-- | runtime/syntax/vim.vim | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/runtime/syntax/vim.vim b/runtime/syntax/vim.vim index 3141e806d1..8d0da8e21f 100644 --- a/runtime/syntax/vim.vim +++ b/runtime/syntax/vim.vim @@ -155,7 +155,7 @@ syn match vimNumber '\%(^\|\A\)\zs#\x\{6}' skipwhite nextgroup=vimGlobal,vimSub syn case match " 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 vimIsCommand "\<\%(\h\w*\|[23]mat\%[ch]\)\>" contains=vimCommand syn match vimVar contained "\<\h[a-zA-Z0-9#_]*\>" @@ -436,16 +436,27 @@ syn match vimAutoCmdMod "\(++\)\=\(once\|nested\)" " Echo And Execute: -- prefer strings! {{{2 " ================ -" GEN_SYN_VIM: vimCommand echo, START_STR='syn keyword vimEcho', END_STR='skipwhite nextgroup=vimEchoExpr' -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 +" NOTE: No trailing comments + +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 keyword vimEchoHLNone none +syn keyword vimEchohlNone contained none 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 " ==== @@ -520,9 +531,8 @@ syn case match " User Function Highlighting: {{{2 " (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 keyword vimFuncEcho contained ec ech echo " User Command Highlighting: {{{2 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 vimCtrlChar SpecialChar hi def link vimEcho vimCommand - hi def link vimEchoHLNone vimGroup - hi def link vimEchoHL vimCommand + hi def link vimEchohlNone vimGroup + hi def link vimEchohl vimCommand hi def link vimElseIfErr Error hi def link vimElseif vimCondHL hi def link vimEnvvar PreProc |