runtime(vim): Update base-syntax and generator, only match valid predefined variables
- Only match valid predefined and option variables. - Match scope dictionaries. - Highlight scope prefixed variables as a scope dictionary accessor. The vimVarScope syntax group can be linked to vimVar to disable this. - Include support for Neovim-only predefined and option variables. Temporary collateral damage - scope dictionaries match instead of keys in dictionary literals. closes: #16727 Signed-off-by: Doug Kearns <dougkearns@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
42e498d9c4
commit
3dca512939
@ -1,7 +1,7 @@
|
||||
" Vim syntax file generator
|
||||
" Language: Vim script
|
||||
" Maintainer: Hirohito Higashi (h_east)
|
||||
" Last Change: 2025 Feb 08
|
||||
" Last Change: 2025 Mar 09
|
||||
|
||||
let s:keepcpo= &cpo
|
||||
set cpo&vim
|
||||
@ -581,6 +581,38 @@ function s:parse_vim_addr_name(li)
|
||||
endtry
|
||||
endfunc
|
||||
|
||||
" ------------------------------------------------------------------------------
|
||||
function s:parse_vim_var(li)
|
||||
try
|
||||
let file_name = $VIM_SRCDIR . '/evalvars.c'
|
||||
let item = {}
|
||||
|
||||
new
|
||||
exec 'read ' . file_name
|
||||
norm! gg
|
||||
exec '/^} vimvars\[VV_LEN] =\n{$/+1;/^};$/-1yank'
|
||||
%delete _
|
||||
|
||||
put
|
||||
g!/^\s*{VV_NAME(/d
|
||||
|
||||
for line in getline(1, line('$'))
|
||||
let list = matchlist(line, '^\s*{VV_NAME("\(\w\+\)"')
|
||||
let item.name = list[1]
|
||||
call add(a:li, copy(item))
|
||||
endfor
|
||||
|
||||
quit!
|
||||
|
||||
if empty(a:li)
|
||||
throw 'var is empty'
|
||||
endif
|
||||
catch /.*/
|
||||
call s:err_gen('')
|
||||
throw 'exit'
|
||||
endtry
|
||||
endfunc
|
||||
|
||||
" ------------------------------------------------------------------------------
|
||||
function s:append_syn_any(lnum, str_info, li)
|
||||
let ret_lnum = a:lnum
|
||||
@ -665,6 +697,15 @@ function s:update_syntax_vim_file(vim_info)
|
||||
let lnum = s:search_and_check(kword . ' term output code', base_fname, str_info)
|
||||
let lnum = s:append_syn_any(lnum, str_info, li)
|
||||
|
||||
" vimOption - normal variable
|
||||
let li = a:vim_info.opt
|
||||
let lnum = s:search_and_check(kword . ' normal variable', base_fname, str_info)
|
||||
let lnum = s:append_syn_vimopt(lnum, str_info, li, '', 0)
|
||||
" vimOption - term output code variable
|
||||
let li = a:vim_info.term_out_code
|
||||
let lnum = s:search_and_check(kword . ' term output code variable', base_fname, str_info)
|
||||
let lnum = s:append_syn_any(lnum, str_info, li)
|
||||
|
||||
" Missing vimOption
|
||||
let li = a:vim_info.missing_opt
|
||||
let lnum = s:search_and_check('Missing vimOption', base_fname, str_info)
|
||||
@ -687,6 +728,11 @@ function s:update_syntax_vim_file(vim_info)
|
||||
let lnum = s:search_and_check('vimFuncName', base_fname, str_info)
|
||||
let lnum = s:append_syn_any(lnum, str_info, li)
|
||||
|
||||
" vimVarName
|
||||
let li = a:vim_info.var
|
||||
let lnum = s:search_and_check('vimVarName', base_fname, str_info)
|
||||
let lnum = s:append_syn_any(lnum, str_info, li)
|
||||
|
||||
" vimUserAttrbCmplt
|
||||
let li = a:vim_info.compl_name
|
||||
let lnum = s:search_and_check('vimUserCmdAttrCmplt', base_fname, str_info)
|
||||
@ -874,6 +920,7 @@ try
|
||||
let s:vim_info.hlgroup = []
|
||||
let s:vim_info.compl_name = []
|
||||
let s:vim_info.addr_name = []
|
||||
let s:vim_info.var = []
|
||||
|
||||
set lazyredraw
|
||||
if !$CHECK_HELP_DOC
|
||||
@ -885,6 +932,7 @@ try
|
||||
silent call s:parse_vim_hlgroup(s:vim_info.hlgroup)
|
||||
silent call s:parse_vim_complete_name(s:vim_info.compl_name)
|
||||
silent call s:parse_vim_addr_name(s:vim_info.addr_name)
|
||||
silent call s:parse_vim_var(s:vim_info.var)
|
||||
|
||||
call s:update_syntax_vim_file(s:vim_info)
|
||||
else
|
||||
|
||||
@ -2,24 +2,30 @@
|
||||
" Language: Vim script
|
||||
" Maintainer: Hirohito Higashi <h.east.727 ATMARK gmail.com>
|
||||
" Doug Kearns <dougkearns@gmail.com>
|
||||
" Last Change: 2025 Mar 06
|
||||
" Last Change: 2025 Mar 09
|
||||
" Former Maintainer: Charles E. Campbell
|
||||
|
||||
" DO NOT CHANGE DIRECTLY.
|
||||
" THIS FILE PARTLY GENERATED BY gen_syntax_vim.vim.
|
||||
" (Search string "GEN_SYN_VIM:" in this file)
|
||||
|
||||
" Automatically generated keyword lists: {{{1
|
||||
|
||||
" Quit when a syntax file was already loaded {{{2
|
||||
" Quit when a syntax file was already loaded {{{1
|
||||
if exists("b:current_syntax")
|
||||
finish
|
||||
endif
|
||||
let s:keepcpo= &cpo
|
||||
set cpo&vim
|
||||
|
||||
" Feature testing {{{1
|
||||
|
||||
let s:vim9script = "\n" .. getline(1, 32)->join("\n") =~# '\n\s*vim9\%[script]\>'
|
||||
|
||||
function s:has(feature)
|
||||
return has(a:feature) || index(get(g:, "vimsyn_vim_features", []), a:feature) != -1
|
||||
endfunction
|
||||
|
||||
" Automatically generated keyword lists: {{{1
|
||||
|
||||
" vimTodo: contains common special-notices for comments {{{2
|
||||
" Use the vimCommentGroup cluster to add your own.
|
||||
syn keyword vimTodo contained COMBAK FIXME TODO XXX
|
||||
@ -41,7 +47,6 @@ syn keyword vimStdPlugin contained Arguments Asm Break Cfilter Clear Continue Di
|
||||
|
||||
" vimOptions: These are the invertible variants {{{2
|
||||
" GEN_SYN_VIM: vimOption invertible, START_STR='syn keyword vimOption contained', END_STR=''
|
||||
|
||||
" termcap codes (which can also be set) {{{2
|
||||
" GEN_SYN_VIM: vimOption term output code, START_STR='syn keyword vimOption contained', END_STR='skipwhite nextgroup=vimSetEqual,vimSetMod'
|
||||
" term key codes
|
||||
@ -55,6 +60,19 @@ syn match vimOption contained "t_&8"
|
||||
syn match vimOption contained "t_%i"
|
||||
syn match vimOption contained "t_k;"
|
||||
|
||||
" vimOptions: These are the variable names {{{2
|
||||
" GEN_SYN_VIM: vimOption normal variable, START_STR='syn keyword vimOptionVarName contained', END_STR=''
|
||||
" GEN_SYN_VIM: vimOption term output code variable, START_STR='syn keyword vimOptionVarName contained', END_STR=''
|
||||
syn keyword vimOptionVarName contained t_F1 t_F2 t_F3 t_F4 t_F5 t_F6 t_F7 t_F8 t_F9 t_k1 t_K1 t_k2 t_k3 t_K3 t_k4 t_K4 t_k5 t_K5 t_k6 t_K6 t_k7 t_K7 t_k8 t_K8 t_k9 t_K9 t_KA t_kb t_kB t_KB t_KC t_kd t_kD t_KD t_KE t_KF t_KG t_kh t_KH t_kI t_KI t_KJ t_KK t_kl t_KL t_kN t_kP t_kr t_ku
|
||||
syn match vimOptionVarName contained "t_%1"
|
||||
syn match vimOptionVarName contained "t_#2"
|
||||
syn match vimOptionVarName contained "t_#4"
|
||||
syn match vimOptionVarName contained "t_@7"
|
||||
syn match vimOptionVarName contained "t_*7"
|
||||
syn match vimOptionVarName contained "t_&8"
|
||||
syn match vimOptionVarName contained "t_%i"
|
||||
syn match vimOptionVarName contained "t_k;"
|
||||
|
||||
" unsupported settings: some were supported by vi but don't do anything in vim {{{2
|
||||
" GEN_SYN_VIM: Missing vimOption, START_STR='syn keyword vimErrSetting contained', END_STR=''
|
||||
|
||||
@ -72,10 +90,20 @@ syn case match
|
||||
|
||||
" Function Names {{{2
|
||||
" GEN_SYN_VIM: vimFuncName, START_STR='syn keyword vimFuncName contained', END_STR=''
|
||||
" Predefined variable names {{{2
|
||||
" GEN_SYN_VIM: vimVarName, START_STR='syn keyword vimVimVarName contained', END_STR=''
|
||||
|
||||
"--- syntax here and above generated by runtime/syntax/generator/gen_syntax_vim.vim ---
|
||||
|
||||
"--- syntax here and above generated by mkvimvim ---
|
||||
" Special Vim Highlighting (not automatic) {{{1
|
||||
|
||||
" Neovim keyword list additions {{{2
|
||||
|
||||
if s:has("nvim")
|
||||
syn keyword vimOptionVarName contained channel inccommand mousescroll pumblend redrawdebug scrollback shada shadafile statuscolumn termpastefilter termsync winbar winblend winhighlight
|
||||
syn keyword vimVimVarName contained lua msgpack_types relnum stderr termrequest virtnum
|
||||
endif
|
||||
|
||||
" Set up commands for this syntax highlighting file {{{2
|
||||
|
||||
com! -nargs=* Vim9 execute <q-args> s:vim9script ? "" : "contained"
|
||||
@ -213,14 +241,17 @@ syn match vimBang contained "!"
|
||||
syn region vimSubscript contained matchgroup=vimSubscriptBracket start="\[" end="]" nextgroup=vimSubscript contains=@vimExprList
|
||||
|
||||
syn match vimVar contained "\<\h[a-zA-Z0-9#_]*\>" nextgroup=vimSubscript contains=vim9Super,vim9This
|
||||
syn match vimVar "\<[bwglstav]:\h[a-zA-Z0-9#_]*\>" nextgroup=vimSubscript
|
||||
syn match vimVar "\<a:\%(000\|\d\+\)\>" nextgroup=vimSubscript
|
||||
syn match vimFBVar contained "\<[bwglsta]:\h[a-zA-Z0-9#_]*\>" nextgroup=vimSubscript
|
||||
syn match vimVar "\<[bwglstav]:\h[a-zA-Z0-9#_]*\>" nextgroup=vimSubscript contains=vimVarScope
|
||||
syn match vimVar "\<a:\%(000\|1\=[0-9]\|20\)\>" nextgroup=vimSubscript contains=vimVarScope
|
||||
syn match vimFBVar contained "\<[bwglsta]:\h[a-zA-Z0-9#_]*\>" nextgroup=vimSubscript contains=vimVarScope
|
||||
|
||||
syn match vimVimVar "\<v:\h\w*\>" nextgroup=vimSubscript
|
||||
syn match vimOptionVar "&\%([lg]:\)\=\a\+\>" nextgroup=vimSubscript
|
||||
syn match vimOptionVar "&t_\S[a-zA-Z0-9]\>" nextgroup=vimSubscript
|
||||
syn match vimOptionVar "&t_k;" nextgroup=vimSubscript
|
||||
" match the scope prefix independently of the retrofitted scope dictionary
|
||||
syn match vimVarScope contained "\<[bwglstav]:"
|
||||
syn match vimVimVar contained "\<[bwglstav]:\%(\h\|\d\)\@!" nextgroup=vimSubscript
|
||||
|
||||
syn match vimVarNameError contained "\<\h\w*\>"
|
||||
syn match vimVimVar "\<v:" nextgroup=vimSubscript,vimVimVarName,vimVarNameError
|
||||
syn match vimOptionVar "&\%([lg]:\)\=" nextgroup=vimSubscript,vimOptionVarName,vimVarNameError
|
||||
syn cluster vimSpecialVar contains=vimEnvvar,vimLetRegister,vimOptionVar,vimVimVar
|
||||
|
||||
Vim9 syn match vim9LhsVariable "\s\=\h[a-zA-Z0-9#_]*\ze\s\+[-+/*%]\=="
|
||||
@ -739,7 +770,7 @@ syn match vimUnletBang contained "\a\@1<=!" skipwhite nextgroup=vimUnletVars
|
||||
syn region vimUnletVars contained
|
||||
\ start="$\I\|\h" skip=+\n\s*\\\|\n\s*"\\ \|^\s*"\\ + end="$" end="\ze[|"]"
|
||||
\ nextgroup=vimCmdSep,vimComment
|
||||
\ contains=@vimContinue,vimEnvvar,vimVar
|
||||
\ contains=@vimContinue,vimEnvvar,vimVar,vimVimVar
|
||||
|
||||
VimFoldh syn region vimLetHereDoc matchgroup=vimLetHereDocStart start='\%(^\z(\s*\)\S.*\)\@<==<<\s*trim\%(\s\+\)\@>\z(\L\S*\)' matchgroup=vimLetHereDocStop end='^\z1\=\z2$' extend
|
||||
VimFoldh syn region vimLetHereDoc matchgroup=vimLetHereDocStart start='=<<\%(\s*\)\@>\z(\L\S*\)' matchgroup=vimLetHereDocStop end='^\z1$' extend
|
||||
@ -1451,7 +1482,7 @@ if !exists("skip_vim_syntax_inits")
|
||||
hi def link vimFuncMod Special
|
||||
hi def link vimFuncParam vimVar
|
||||
hi def link vimFuncParamEquals vimOper
|
||||
hi def link vimFuncScope vimVar
|
||||
hi def link vimFuncScope vimVarScope
|
||||
hi def link vimFuncSID vimNotation
|
||||
hi def link vimGroupAdd vimSynOption
|
||||
hi def link vimGroupName vimGroup
|
||||
@ -1521,7 +1552,7 @@ if !exists("skip_vim_syntax_inits")
|
||||
hi def link vimOperContinueComment vimContinueComment
|
||||
hi def link vimOption PreProc
|
||||
hi def link vimOptionVar Identifier
|
||||
hi def link vimVimVar Identifier
|
||||
hi def link vimOptionVarName Identifier
|
||||
hi def link vimParenSep Delimiter
|
||||
hi def link vimPatSepErr vimError
|
||||
hi def link vimPatSepR vimPatSep
|
||||
@ -1605,6 +1636,9 @@ if !exists("skip_vim_syntax_inits")
|
||||
hi def link vimUserCmdKey vimCommand
|
||||
hi def link vimUserFunc Normal
|
||||
hi def link vimVar Normal
|
||||
hi def link vimVarScope Identifier
|
||||
hi def link vimVimVar Identifier
|
||||
hi def link vimVimVarName Identifier
|
||||
hi def link vimWarn WarningMsg
|
||||
|
||||
hi def link vim9Abstract vimCommand
|
||||
|
||||
Reference in New Issue
Block a user