vim-patch:69866449ddb2

runtime(vim): Improve keymap file highlighting (vim/vim#13550)

- Match :loadkeymap to EOF as a region and contain only allowed items.
- Add highlighting for <Char- notation.
- add basic syntax highlighting tests

69866449dd

N/A patches:
vim-patch:35928ee8f80ea721e92bb856c8ecde2cced46bb9
vim-patch:b5352931b354eb67eb7d223cc09c98dcf1b547b6

Co-authored-by: dkearns <dougkearns@gmail.com>
This commit is contained in:
zeertzjq 2024-02-02 06:41:10 +08:00
parent 05fd70f19b
commit 882d5fa558

View File

@ -234,7 +234,20 @@ syn match vimFuncBlank contained "\s\+"
syn keyword vimPattern contained start skip end
" vimTypes : new for vim9
syn match vimType ":\s*\zs\<\(bool\|number\|float\|string\|blob\|list<\|dict<\|job\|channel\|func\)\>"
syn match vimType ":\s*\zs\<\(bool\|number\|float\|string\|blob\|list<\|dict<\|job\|channel\|func\)\>"
" Keymaps: (Vim Project Addition) {{{2
" =======
" TODO: autogenerated vimCommand keyword list does not handle all abbreviations
" : handle Vim9 script comments when something like #13104 is merged
syn match vimKeymapStart "^" contained skipwhite nextgroup=vimKeymapLhs,vimKeymapLineComment
syn match vimKeymapLhs "\S\+" contained skipwhite nextgroup=vimKeymapRhs contains=vimNotation
syn match vimKeymapRhs "\S\+" contained skipwhite nextgroup=vimKeymapTailComment contains=vimNotation
syn match vimKeymapTailComment "\S.*" contained
syn match vimKeymapLineComment +".*+ contained contains=@vimCommentGroup,vimCommentString,vimCommentTitle
syn region vimKeymap matchgroup=vimCommand start="\<loadk\%[eymap]\>" end="\%$" contains=vimKeymapStart
" Special Filenames, Modifiers, Extension Removal: {{{2
" ===============================================
@ -451,6 +464,7 @@ syn match vimNotation "\%#=1\(\\\|<lt>\)\=<\(bslash\|plug\|sid\|space\|bar\|nop\
syn match vimNotation '\(\\\|<lt>\)\=<C-R>[0-9a-z"%#:.\-=]'he=e-1 contains=vimBracket
syn match vimNotation '\%#=1\(\\\|<lt>\)\=<\%(q-\)\=\(line[12]\|count\|bang\|reg\|args\|mods\|f-args\|f-mods\|lt\)>' contains=vimBracket
syn match vimNotation "\%#=1\(\\\|<lt>\)\=<\([cas]file\|abuf\|amatch\|cword\|cWORD\|client\)>" contains=vimBracket
syn match vimNotation "\%#=1\(\\\|<lt>\)\=<\%([scamd]-\)\{0,4}char-\%(\d\+\|0\o\+\|0x\x\+\)>" contains=vimBracket
syn match vimBracket contained "[\\<>]"
syn case match
@ -946,6 +960,8 @@ if !exists("skip_vim_syntax_inits")
hi def link vimInsert vimString
hi def link vimIskSep Delimiter
hi def link vimKeyCode vimSpecFile
hi def link vimKeymapLineComment vimComment
hi def link vimKeymapTailComment vimComment
hi def link vimKeyword Statement
hi def link vimLet vimCommand
hi def link vimLetHereDoc vimString