0
0
mirror of https://github.com/vim/vim.git synced 2025-07-04 23:07:33 -04:00

runtime(vim): Update base-syntax, improve :map highlighting (#14141)

Improve :map command highlighting.

- Fix multiline RHS matching, allow continued lines and comments.
- Allow ^V-escaped whitespace in LHS.
- Handle map-bar properly and allow trailing commands.

Fixes issue #12672.


Signed-off-by: Doug Kearns <dougkearns@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
dkearns 2024-03-10 04:01:22 +11:00 committed by GitHub
parent 13a014452a
commit 5d67aef306
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 178 additions and 28 deletions

View File

@ -467,11 +467,13 @@ syn match vimMap "\<map!" contains=vimMapBang skipwhite nextgroup=vimMapMod,v
" GEN_SYN_VIM: vimCommand mapclear, START_STR='syn keyword vimMap', END_STR='skipwhite nextgroup=vimMapMod' " GEN_SYN_VIM: vimCommand mapclear, START_STR='syn keyword vimMap', END_STR='skipwhite nextgroup=vimMapMod'
syn keyword vimMap mapc[lear] skipwhite nextgroup=vimMapBang,vimMapMod syn keyword vimMap mapc[lear] skipwhite nextgroup=vimMapBang,vimMapMod
" GEN_SYN_VIM: vimCommand unmap, START_STR='syn keyword vimUnmap', END_STR='skipwhite nextgroup=vimMapBang,vimMapMod,vimMapLhs' " GEN_SYN_VIM: vimCommand unmap, START_STR='syn keyword vimUnmap', END_STR='skipwhite nextgroup=vimMapBang,vimMapMod,vimMapLhs'
syn match vimMapLhs contained "\S\+" contains=vimNotation,vimCtrlChar skipwhite nextgroup=vimMapRhs syn match vimMapLhs contained "\%(.\|\S\)\+" contains=vimCtrlChar,vimNotation skipwhite nextgroup=vimMapRhs
syn match vimMapLhs contained "\%(.\|\S\)\+\ze\s*$" contains=vimCtrlChar,vimNotation skipwhite skipnl nextgroup=vimMapRhsContinue
syn match vimMapBang contained "\a\@1<=!" skipwhite nextgroup=vimMapMod,vimMapLhs syn match vimMapBang contained "\a\@1<=!" skipwhite nextgroup=vimMapMod,vimMapLhs
syn match vimMapMod contained "\%#=1\c<\(buffer\|expr\|\(local\)\=leader\|nowait\|plug\|script\|sid\|unique\|silent\)\+>" contains=vimMapModKey,vimMapModErr skipwhite nextgroup=vimMapMod,vimMapLhs syn match vimMapMod contained "\%#=1\c<\(buffer\|expr\|\(local\)\=leader\|nowait\|plug\|script\|sid\|unique\|silent\)\+>" contains=vimMapModKey,vimMapModErr skipwhite nextgroup=vimMapMod,vimMapLhs
syn match vimMapRhs contained ".*" contains=vimNotation,vimCtrlChar skipnl nextgroup=vimMapRhsExtend syn region vimMapRhs contained start="\S" skip=+\\|\|\@1<=|\|\n\s*\\\|\n\s*"\\ + end="|" end="$" contains=@vimContinue,vimCtrlChar,vimNotation skipnl nextgroup=vimMapRhsContinue
syn match vimMapRhsExtend contained "^\s*\\.*$" contains=vimContinue " assume a continuation comment introduces the RHS
syn region vimMapRhsContinue contained start=+^\s*\%(\\\|"\\ \)+ skip=+\\|\|\@1<=|\|\n\s*\\\|\n\s*"\\ + end="|" end="$" contains=@vimContinue,vimCtrlChar,vimNotation
syn case ignore syn case ignore
syn keyword vimMapModKey contained buffer expr leader localleader nowait plug script sid silent unique syn keyword vimMapModKey contained buffer expr leader localleader nowait plug script sid silent unique
syn case match syn case match
@ -1137,4 +1139,4 @@ delc VimFoldr
delc VimFoldt delc VimFoldt
let &cpo = s:keepcpo let &cpo = s:keepcpo
unlet s:keepcpo unlet s:keepcpo
" vim:ts=18 fdm=marker " vim:ts=18 fdm=marker ft=vim

View File

@ -0,0 +1,20 @@
|v+0#af5f00255#ffffff0|m|a|p|c|l|e|a|r| +0#0000000&|<+0#e000e06&|b|u|f@1|e|r|>| +0#0000000&@56
|x+0#af5f00255&|m|a|p|c|l|e|a|r| +0#0000000&|<+0#e000e06&|b|u|f@1|e|r|>| +0#0000000&@56
|s+0#af5f00255&|m|a|p|c|l|e|a|r| +0#0000000&|<+0#e000e06&|b|u|f@1|e|r|>| +0#0000000&@56
|o+0#af5f00255&|m|a|p|c|l|e|a|r| +0#0000000&|<+0#e000e06&|b|u|f@1|e|r|>| +0#0000000&@56
|i+0#af5f00255&|m|a|p|c|l|e|a|r| +0#0000000&|<+0#e000e06&|b|u|f@1|e|r|>| +0#0000000&@56
>l+0#af5f00255&|m|a|p|c|l|e|a|r| +0#0000000&|<+0#e000e06&|b|u|f@1|e|r|>| +0#0000000&@56
|c+0#af5f00255&|m|a|p|c|l|e|a|r| +0#0000000&|<+0#e000e06&|b|u|f@1|e|r|>| +0#0000000&@56
|t+0#af5f00255&|m|a|p|c|l|e|a|r| +0#0000000&|<+0#e000e06&|b|u|f@1|e|r|>| +0#0000000&@56
@75
@75
|"+0#0000e05&| |:|h|e|l|p| |m|a|p|-|b|a|r| +0#0000000&@59
@75
|"+0#0000e05&| |<|B|a|r|>| @4|'|<|'| |i|s| |n|o|t| |i|n| |'|c|p|o|p|t|i|o|n|s|'| +0#0000000&@37
|m+0#af5f00255&|a|p| +0#0000000&|_|l| |:|!|l|s| |<+0#e000e06&|B|a|r|>| +0#0000000&|m|o|r|e|^|M|:|e|c|h|o| |"|r|h|s|"|<+0#e000e06&|C|R|>| +0#0000000&@35
|"+0#0000e05&| |\||| @7|'|b|'| |i|s| |n|o|t| |i|n| |'|c|p|o|p|t|i|o|n|s|'| +0#0000000&@37
|m+0#af5f00255&|a|p| +0#0000000&|_|l| |:|!|l|s| |\||| |m|o|r|e|^|M|:|e|c|h|o| |"|r|h|s|"|<+0#e000e06&|C|R|>| +0#0000000&@38
|"+0#0000e05&| |^|V||| @6|a|l|w|a|y|s|,| |i|n| |V|i|m| |a|n|d| |V|i| +0#0000000&@41
|m+0#af5f00255&|a|p| +0#0000000&|_|l| |:|!|l|s| |^+0#0000e05&|V||+0#0000000&| |m|o|r|e|^|M|:|e|c|h|o| |"|r|h|s|"|<+0#e000e06&|C|R|>| +0#0000000&@37
@75
@57|1|9|,|1| @9|1|9|%|

View File

@ -0,0 +1,20 @@
| +0&#ffffff0@74
|m+0#af5f00255&|a|p| +0#0000000&|l|h|s| |:|s|e|a|r|c|h|(|'|f|o@1|\@1|||b|a|r|'|)|<+0#e000e06&|C|R|>|:+0#0000000&|e|c|h|o| |"|r|h|s|"|<+0#e000e06&|C|R|>| +0#0000000&@27
@75
@75
|"+0#0000e05&| |m|u|l|t|i|l|i|n|e| |R|H|S| +0#0000000&@59
> @74
|m+0#af5f00255&|a|p| +0#0000000&|<+0#e000e06&|l|e|a|d|e|r|>|b+0#0000000&|a|z| @59
@2|\+0#e000e06&| +0#0000000&|:|e|c|h|o| |(|<+0#e000e06&|b|a|r|>| +0#0000000&@58
@2|\+0#e000e06&| +0#0000000&@71
@2|\+0#e000e06&|'+0#0000000&|b|a|r|'|)|<+0#e000e06&|c|r|>| +0#0000000&@61
@2|"+0#0000e05&|\| |c|o|m@1|e|n|t| +0#0000000&@62
@75
|m+0#af5f00255&|a|p| +0#0000000&|l|h|s| @67
@2|"+0#0000e05&|\| |c|o|m@1|e|n|t| +0#0000000&@62
@2|\+0#e000e06&| +0#0000000&|e|c|h|o| |"|f|o@1|"| @60
@75
|m+0#af5f00255&|a|p| +0#0000000&|l|h|s| @67
@2|"+0#0000e05&|\| |c|o|m@1|e|n|t| +0#0000000&@62
@2|\+0#e000e06&| +0#0000000&|e|c|h|o| |"|f|o@1|"| @60
@57|3|7|,|0|-|1| @7|4|5|%|

View File

@ -0,0 +1,20 @@
| +0&#ffffff0@1|\+0#e000e06&| +0#0000000&|e|c|h|o| |"|f|o@1|"| @60
@75
|m+0#af5f00255&|a|p| +0#0000000&|l|h|s|^+0#0000e05&|V| +0#0000000&@65
@2|"+0#0000e05&|\| |c|o|m@1|e|n|t| +0#0000000&@62
@2|\+0#e000e06&| +0#0000000&|e|c|h|o| |"|f|o@1|"| @60
> @74
|m+0#af5f00255&|a|p| +0#0000000&|l|^+0#0000e05&|V| +0#0000000&|h|s| @64
@2|"+0#0000e05&|\| |c|o|m@1|e|n|t| +0#0000000&@62
@2|\+0#e000e06&| +0#0000000&|e|c|h|o| |"|f|o@1|"| @60
@75
|m+0#af5f00255&|a|p| +0#0000000&|l|^+0#0000e05&|V| +0#0000000&|h|s| @64
@2|"+0#0000e05&|\| |c|o|m@1|e|n|t| +0#0000000&@62
@2|\+0#e000e06&| +0#0000000&|e|c|h|o| |"|f|o@1|"| @60
@75
|m+0#af5f00255&|a|p| +0#0000000&|l|h|s| |r|h|s| @63
|m+0#af5f00255&|a|p| +0#0000000&|l|^+0#0000e05&|V| +0#0000000&|h|^+0#0000e05&|V| +0#0000000&|s|^+0#0000e05&|V| +0#0000000&@1|r|h|s| @54
@75
|m+0#af5f00255&|a|p| +0#0000000&|l|h|s| @67
@2|"+0#0000e05&|\| |c|o|m@1|e|n|t| |(|m|a|t|c|h|e|s| |a|s| |R|H|S| |b|u|t| |h|a|r|m|l|e|s@1|)| +0#0000000&@32
@57|5@1|,|0|-|1| @7|7|2|%|

View File

@ -0,0 +1,20 @@
| +0&#ffffff0@1|"+0#0000e05&|\| |c|o|m@1|e|n|t| |(|m|a|t|c|h|e|s| |a|s| |R|H|S| |b|u|t| |h|a|r|m|l|e|s@1|)| +0#0000000&@32
|e+0#af5f00255&|c|h|o| +0#0000000&|"+0#e000002&|c|l|e|a|r|"| +0#0000000&@62
@75
@75
|"+0#0000e05&| |I|s@1|u|e| @1|#|1|2|6|7|2| +0#0000000&@59
> @74
|n+0#af5f00255&@1|o|r|e|m|a|p| +0#0000000&|<+0#e000e06&|l|e|a|d|e|r|>|f+0#0000000&|o@1| |:|e|c|h|o| |c|a|l@1|(| @42
@2|"+0#0000e05&|\| |c|o|m@1|e|n|t| +0#0000000&@62
@2|\+0#e000e06&| +0#0000000&|{|x|-|>|x|}|,| @63
@2|\+0#e000e06&| +0#0000000&|[|'|f|o@1|'|]|)|<+0#e000e06&|c|r|>| +0#0000000&@58
@75
|n+0#af5f00255&@1|o|r|e|m|a|p| +0#0000000&|<+0#e000e06&|l|e|a|d|e|r|>|b+0#0000000&|a|r| |:|e|c|h|o| |(| @46
@2|\+0#e000e06&| +0#0000000&@71
@2|\+0#e000e06&| +0#0000000&|'|b|a|r|'|)|<+0#e000e06&|c|r|>| +0#0000000&@60
@75
@75
|"+0#0000e05&| +0#0000000&|E+0#e000e06&|x|a|m|p|l|e|:| +0#0000000&@64
|"+0#0000e05&| @2|/|a|u|t|o|l|o|a|d|/|n|e|t|r|w|.|v|i|m| +0#0000000&@51
@75
@57|7|3|,|0|-|1| @7|9|8|%|

View File

@ -1,20 +1,20 @@
|m+0#af5f00255#ffffff0|a|p|!| +0#0000000&@70 | +0&#ffffff0@74
|m+0#af5f00255&|a|p|!| +0#0000000&|l|h|s| |r|h|s| @62
|m+0#af5f00255&|a|p| +0#0000000&@71
|m+0#af5f00255&|a|p| +0#0000000&|l|h|s| |r|h|s| @63
@75 @75
|c+0#af5f00255&|a|l@1| +0#0000000&|m+0#00e0e07&|a|p|(+0#e000e06&|l+0#00e0e07&|i|s|t|,+0#0000000&| |'+0#e000002&|v|:|v|a|l|'|)+0#e000e06&| +0#0000000&@51 |"+0#0000e05&| |I|s@1|u|e| @1|#|1|2|6|7|2| +0#0000000&@59
|c+0#af5f00255&|a|l@1| +0#0000000&|m+0#00e0e07&|a|p| +0#0000000&|(+0#e000e06&|l+0#00e0e07&|i|s|t|,+0#0000000&| |'+0#e000002&|v|:|v|a|l|'|)+0#e000e06&| +0#0000000&@50
@75 @75
|m+0#af5f00255&|a|p|c|l|e|a|r| +0#0000000&@1|<+0#e000e06&|b|u|f@1|e|r|>| +0#0000000&@56 |n+0#af5f00255&@1|o|r|e|m|a|p| +0#0000000&|<+0#e000e06&|l|e|a|d|e|r|>|f+0#0000000&|o@1| |:|e|c|h|o| |c|a|l@1|(| @42
|m+0#af5f00255&|a|p|c|l|e|a|r|!| +0#0000000&|<+0#e000e06&|b|u|f@1|e|r|>| +0#0000000&@56 @2|"+0#0000e05&|\| |c|o|m@1|e|n|t| +0#0000000&@62
|n+0#af5f00255&|m|a|p|c|l|e|a|r| +0#0000000&|<+0#e000e06&|b|u|f@1|e|r|>| +0#0000000&@56 @2|\+0#e000e06&| +0#0000000&|{|x|-|>|x|}|,| @63
|v+0#af5f00255&|m|a|p|c|l|e|a|r| +0#0000000&|<+0#e000e06&|b|u|f@1|e|r|>| +0#0000000&@56 @2|\+0#e000e06&| +0#0000000&|[|'|f|o@1|'|]|)|<+0#e000e06&|c|r|>| +0#0000000&@58
|x+0#af5f00255&|m|a|p|c|l|e|a|r| +0#0000000&|<+0#e000e06&|b|u|f@1|e|r|>| +0#0000000&@56 @75
|s+0#af5f00255&|m|a|p|c|l|e|a|r| +0#0000000&|<+0#e000e06&|b|u|f@1|e|r|>| +0#0000000&@56 |n+0#af5f00255&@1|o|r|e|m|a|p| +0#0000000&|<+0#e000e06&|l|e|a|d|e|r|>|b+0#0000000&|a|r| |:|e|c|h|o| |(| @46
|o+0#af5f00255&|m|a|p|c|l|e|a|r| +0#0000000&|<+0#e000e06&|b|u|f@1|e|r|>| +0#0000000&@56 @2|\+0#e000e06&| +0#0000000&@71
|i+0#af5f00255&|m|a|p|c|l|e|a|r| +0#0000000&|<+0#e000e06&|b|u|f@1|e|r|>| +0#0000000&@56 @2|\+0#e000e06&| +0#0000000&|'|b|a|r|'|)|<+0#e000e06&|c|r|>| +0#0000000&@60
|l+0#af5f00255&|m|a|p|c|l|e|a|r| +0#0000000&|<+0#e000e06&|b|u|f@1|e|r|>| +0#0000000&@56 @75
|c+0#af5f00255&|m|a|p|c|l|e|a|r| +0#0000000&|<+0#e000e06&|b|u|f@1|e|r|>| +0#0000000&@56 @75
>t+0#af5f00255&|m|a|p|c|l|e|a|r| +0#0000000&|<+0#e000e06&|b|u|f@1|e|r|>| +0#0000000&@56 |"+0#0000e05&| +0#0000000&|E+0#e000e06&|x|a|m|p|l|e|:| +0#0000000&@64
@57|2|1|,|1| @9|B|o|t| |"+0#0000e05&| @2|/|a|u|t|o|l|o|a|d|/|n|e|t|r|w|.|v|i|m| +0#0000000&@51
@75
>i+0#af5f00255&|f| +0#0000000&|!+0#af5f00255&|h+0#00e0e07&|a|s|m|a|p|t|o|(+0#e000e06&|'+0#e000002&|<|P|l|u|g|>|N|e|t|r|w|O|p|e|n|F|i|l|e|'|)+0#e000e06&| +0#0000000&@9|||n+0#af5f00255&|m|a|p| +0#0000000&|<+0#e000e06&|b|u|f@1|e|r|>| +0#0000000&|<+0#e000e06&|s|i|l|e|n|t|>| +0#0000000&|<+0#e000e06&|n|o|w|a|i
|t|>| +0#0000000&|%| |<+0#e000e06&|P|l|u|g|>|N+0#0000000&|e|t|r|w|O|p|e|n|F|i|l|e|||e+0#af5f00255&|n|d|i|f| +0#0000000&@44
@57|8|7|,|1| @9|B|o|t|

View File

@ -19,3 +19,69 @@ imapclear <buffer>
lmapclear <buffer> lmapclear <buffer>
cmapclear <buffer> cmapclear <buffer>
tmapclear <buffer> tmapclear <buffer>
" :help map-bar
" <Bar> '<' is not in 'cpoptions'
map _l :!ls <Bar> more^M:echo "rhs"<CR>
" \| 'b' is not in 'cpoptions'
map _l :!ls \| more^M:echo "rhs"<CR>
" ^V| always, in Vim and Vi
map _l :!ls | more^M:echo "rhs"<CR>
map lhs :search('foo\\|bar')<CR>:echo "rhs"<CR>
" multiline RHS
map <leader>baz
\ :echo (<bar>
\
\'bar')<cr>
"\ comment
map lhs
"\ comment
\ echo "foo"
map lhs
"\ comment
\ echo "foo"
map lhs
"\ comment
\ echo "foo"
map l hs
"\ comment
\ echo "foo"
map l hs
"\ comment
\ echo "foo"
map lhs rhs
map l h s rhs
map lhs
"\ comment (matches as RHS but harmless)
echo "clear"
" Issue #12672
nnoremap <leader>foo :echo call(
"\ comment
\ {x->x},
\ ['foo'])<cr>
nnoremap <leader>bar :echo (
\
\ 'bar')<cr>
" Example:
" /autoload/netrw.vim
if !hasmapto('<Plug>NetrwOpenFile') |nmap <buffer> <silent> <nowait> % <Plug>NetrwOpenFile|endif

View File

@ -511,11 +511,13 @@ syn keyword vimMap cmapc[lear] imapc[lear] lmapc[lear] nmapc[lear] omapc[lear] s
syn keyword vimMap mapc[lear] skipwhite nextgroup=vimMapBang,vimMapMod syn keyword vimMap mapc[lear] skipwhite nextgroup=vimMapBang,vimMapMod
" GEN_SYN_VIM: vimCommand unmap, START_STR='syn keyword vimUnmap', END_STR='skipwhite nextgroup=vimMapBang,vimMapMod,vimMapLhs' " GEN_SYN_VIM: vimCommand unmap, START_STR='syn keyword vimUnmap', END_STR='skipwhite nextgroup=vimMapBang,vimMapMod,vimMapLhs'
syn keyword vimUnmap cu[nmap] iu[nmap] lu[nmap] nun[map] ou[nmap] sunm[ap] tunma[p] unm[ap] vu[nmap] xu[nmap] skipwhite nextgroup=vimMapBang,vimMapMod,vimMapLhs syn keyword vimUnmap cu[nmap] iu[nmap] lu[nmap] nun[map] ou[nmap] sunm[ap] tunma[p] unm[ap] vu[nmap] xu[nmap] skipwhite nextgroup=vimMapBang,vimMapMod,vimMapLhs
syn match vimMapLhs contained "\S\+" contains=vimNotation,vimCtrlChar skipwhite nextgroup=vimMapRhs syn match vimMapLhs contained "\%(.\|\S\)\+" contains=vimCtrlChar,vimNotation skipwhite nextgroup=vimMapRhs
syn match vimMapLhs contained "\%(.\|\S\)\+\ze\s*$" contains=vimCtrlChar,vimNotation skipwhite skipnl nextgroup=vimMapRhsContinue
syn match vimMapBang contained "\a\@1<=!" skipwhite nextgroup=vimMapMod,vimMapLhs syn match vimMapBang contained "\a\@1<=!" skipwhite nextgroup=vimMapMod,vimMapLhs
syn match vimMapMod contained "\%#=1\c<\(buffer\|expr\|\(local\)\=leader\|nowait\|plug\|script\|sid\|unique\|silent\)\+>" contains=vimMapModKey,vimMapModErr skipwhite nextgroup=vimMapMod,vimMapLhs syn match vimMapMod contained "\%#=1\c<\(buffer\|expr\|\(local\)\=leader\|nowait\|plug\|script\|sid\|unique\|silent\)\+>" contains=vimMapModKey,vimMapModErr skipwhite nextgroup=vimMapMod,vimMapLhs
syn match vimMapRhs contained ".*" contains=vimNotation,vimCtrlChar skipnl nextgroup=vimMapRhsExtend syn region vimMapRhs contained start="\S" skip=+\\|\|\@1<=|\|\n\s*\\\|\n\s*"\\ + end="|" end="$" contains=@vimContinue,vimCtrlChar,vimNotation skipnl nextgroup=vimMapRhsContinue
syn match vimMapRhsExtend contained "^\s*\\.*$" contains=vimContinue " assume a continuation comment introduces the RHS
syn region vimMapRhsContinue contained start=+^\s*\%(\\\|"\\ \)+ skip=+\\|\|\@1<=|\|\n\s*\\\|\n\s*"\\ + end="|" end="$" contains=@vimContinue,vimCtrlChar,vimNotation
syn case ignore syn case ignore
syn keyword vimMapModKey contained buffer expr leader localleader nowait plug script sid silent unique syn keyword vimMapModKey contained buffer expr leader localleader nowait plug script sid silent unique
syn case match syn case match
@ -1182,4 +1184,4 @@ delc VimFoldr
delc VimFoldt delc VimFoldt
let &cpo = s:keepcpo let &cpo = s:keepcpo
unlet s:keepcpo unlet s:keepcpo
" vim:ts=18 fdm=marker " vim:ts=18 fdm=marker ft=vim