runtime(vim): Update base syntax and generator, improve command/function distinction
- Match Ex command modifiers and functions with the same name correctly. E.g., :browse and browse(). - Match full :eval command. closes: #17789 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
2e58b7684f
commit
2f7c957c8d
@ -1,7 +1,7 @@
|
||||
" Vim syntax file generator
|
||||
" Language: Vim script
|
||||
" Maintainer: Hirohito Higashi (h_east)
|
||||
" Last Change: 2025 Jul 03
|
||||
" Last Change: 2025 Jul 18
|
||||
|
||||
let s:keepcpo= &cpo
|
||||
set cpo&vim
|
||||
@ -234,39 +234,48 @@ function s:parse_vim_command(cmd)
|
||||
endtry
|
||||
endfunc
|
||||
|
||||
function s:get_cmd_modifiers()
|
||||
try
|
||||
let file_name = $VIM_SRCDIR .. '/ex_docmd.c'
|
||||
|
||||
new
|
||||
exec 'read ' .. file_name
|
||||
norm! gg
|
||||
exec ':/^static cmdmod_info_T cmdmod_info_tab\[] = {/+1;/^};/-1yank'
|
||||
%delete _
|
||||
|
||||
put
|
||||
1delete _
|
||||
|
||||
let modifiers = []
|
||||
let list = []
|
||||
for line in getline(1, line('$'))
|
||||
let list = matchlist(line, '^\s*{"\(\w\+\)".*')
|
||||
call add(modifiers, copy(list[1]))
|
||||
endfor
|
||||
|
||||
quit!
|
||||
|
||||
function s:memoize_cmd_modifiers()
|
||||
let modifiers = []
|
||||
function _() closure
|
||||
if empty(modifiers)
|
||||
throw 'cmd modifiers list is empty'
|
||||
try
|
||||
let file_name = $VIM_SRCDIR .. '/ex_docmd.c'
|
||||
|
||||
new
|
||||
exec 'read ' .. file_name
|
||||
norm! gg
|
||||
exec ':/^static cmdmod_info_T cmdmod_info_tab\[] = {/+1;/^};/-1yank'
|
||||
%delete _
|
||||
|
||||
put
|
||||
1delete _
|
||||
|
||||
let list = []
|
||||
for line in getline(1, line('$'))
|
||||
let list = matchlist(line, '^\s*{"\(\w\+\)".*')
|
||||
" :browse and :confirm handled separately as lower priority matches
|
||||
" because they have same-named builtin functions
|
||||
if index(['browse', 'confirm'], list[1]) == -1
|
||||
call add(modifiers, copy(list[1]))
|
||||
endif
|
||||
endfor
|
||||
|
||||
quit!
|
||||
|
||||
if empty(modifiers)
|
||||
throw 'cmd modifiers list is empty'
|
||||
endif
|
||||
|
||||
catch /.*/
|
||||
call s:err_gen('')
|
||||
throw 'exit'
|
||||
endtry
|
||||
endif
|
||||
|
||||
return modifiers
|
||||
|
||||
catch /.*/
|
||||
call s:err_gen('')
|
||||
throw 'exit'
|
||||
endtry
|
||||
endfunction
|
||||
return function("_")
|
||||
endfunction
|
||||
let s:get_cmd_modifiers = s:memoize_cmd_modifiers()
|
||||
|
||||
function s:get_vim_command_type(cmd_name)
|
||||
" Return value:
|
||||
@ -296,10 +305,13 @@ function s:get_vim_command_type(cmd_name)
|
||||
behave
|
||||
call
|
||||
catch
|
||||
chdir
|
||||
class
|
||||
copy
|
||||
debuggreedy
|
||||
def
|
||||
delcommand
|
||||
delete
|
||||
delfunction
|
||||
doautoall
|
||||
doautocmd
|
||||
@ -319,6 +331,7 @@ function s:get_vim_command_type(cmd_name)
|
||||
endif
|
||||
endinterface
|
||||
enum
|
||||
eval
|
||||
execute
|
||||
export
|
||||
filetype
|
||||
@ -333,6 +346,7 @@ function s:get_vim_command_type(cmd_name)
|
||||
import
|
||||
interface
|
||||
insert
|
||||
join
|
||||
k
|
||||
let
|
||||
loadkeymap
|
||||
@ -378,8 +392,10 @@ function s:get_vim_command_type(cmd_name)
|
||||
smagic
|
||||
snomagic
|
||||
sort
|
||||
split
|
||||
static
|
||||
substitute
|
||||
swapname
|
||||
syntax
|
||||
tcl
|
||||
tcldo
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
" Language: Vim script
|
||||
" Maintainer: Hirohito Higashi <h.east.727 ATMARK gmail.com>
|
||||
" Doug Kearns <dougkearns@gmail.com>
|
||||
" Last Change: 2025 Jul 17
|
||||
" Last Change: 2025 Jul 18
|
||||
" Former Maintainer: Charles E. Campbell
|
||||
|
||||
" DO NOT CHANGE DIRECTLY.
|
||||
@ -34,10 +34,22 @@ syn cluster vimCommentGroup contains=vimTodo,@Spell
|
||||
" regular vim commands {{{2
|
||||
" GEN_SYN_VIM: vimCommand normal, START_STR='syn keyword vimCommand contained', END_STR='nextgroup=vimBang'
|
||||
|
||||
" Lower priority :syn-match to allow for :command/function() distinction
|
||||
syn match vimCommand "\<chd\%[ir]\>" nextgroup=vimBang
|
||||
syn match vimCommand "\<co\%[py]\>" nextgroup=vimBang
|
||||
syn match vimCommand "\<d\%[elete]\>" nextgroup=vimBang
|
||||
syn match vimCommand "\<j\%[oin]\>" nextgroup=vimBang
|
||||
syn match vimCommand "\<sp\%[lit]\>" nextgroup=vimBang
|
||||
syn match vimCommand "\<sw\%[apname]\>" nextgroup=vimBang
|
||||
|
||||
" GEN_SYN_VIM: vimCommand modifier, START_STR='syn keyword vimCommandModifier', END_STR='skipwhite nextgroup=vimCommandModifierBang,@vimCmdList'
|
||||
" :filter is handled specially elsewhere
|
||||
syn match vimCommandModifierBang contained "\a\@1<=!" skipwhite nextgroup=@vimCmdList
|
||||
|
||||
" Lower priority :syn-match to allow for :command/function() distinction
|
||||
syn match vimCommand "\<bro\%[wse]\>" skipwhite nextgroup=vimCommandModifierBang,@vimCmdList
|
||||
syn match vimCommand "\<conf\%[irm]\>" skipwhite nextgroup=vimCommandModifierBang,@vimCmdList
|
||||
|
||||
" Lower priority for _new_ to distinguish constructors from the command.
|
||||
syn match vimCommand contained "\<new\>(\@!"
|
||||
syn match vimCommand contained "\<z[-+^.=]\=\>"
|
||||
@ -230,7 +242,7 @@ syn match vimNumber '\<0z\%(\x\x\)\+\%(\.\%(\x\x\)\+\)*' skipwhite nextgroup=@vi
|
||||
syn case match
|
||||
|
||||
" All vimCommands are contained by vimIsCommand. {{{2
|
||||
syn cluster vimCmdList contains=vimAbb,vimAddress,vimAutocmd,vimAugroup,vimBehave,vimCall,vimCatch,vimCommandModifier,vimConst,vimDoautocmd,vimDebuggreedy,vimDef,vimDefFold,vimDelcommand,vimDelFunction,@vimEcho,vimElse,vimEnddef,vimEndfunction,vimEndif,vimExecute,vimIsCommand,vimExtCmd,vimExFilter,vimExMark,vimFiletype,vimFor,vimFunction,vimFunctionFold,vimGrep,vimGrepAdd,vimGlobal,vimHelpgrep,vimHighlight,vimImport,vimLet,vimLoadkeymap,vimLockvar,vimMake,vimMap,vimMark,vimMatch,vimNotFunc,vimNormal,vimProfdel,vimProfile,vimRedir,vimSet,vimSleep,vimSort,vimSyntax,vimSynColor,vimSynLink,vimThrow,vimUniq,vimUnlet,vimUnlockvar,vimUnmap,vimUserCmd,vimVimgrep,vimVimgrepadd,vimMenu,vimMenutranslate,@vim9CmdList,@vimExUserCmdList,vimLua,vimMzScheme,vimPerl,vimPython,vimPython3,vimPythonX,vimRuby,vimTcl
|
||||
syn cluster vimCmdList contains=vimAbb,vimAddress,vimAutocmd,vimAugroup,vimBehave,vimCall,vimCatch,vimCommandModifier,vimConst,vimDoautocmd,vimDebuggreedy,vimDef,vimDefFold,vimDelcommand,vimDelFunction,@vimEcho,vimElse,vimEnddef,vimEndfunction,vimEndif,vimEval,vimExecute,vimIsCommand,vimExtCmd,vimExFilter,vimExMark,vimFiletype,vimFor,vimFunction,vimFunctionFold,vimGrep,vimGrepAdd,vimGlobal,vimHelpgrep,vimHighlight,vimImport,vimLet,vimLoadkeymap,vimLockvar,vimMake,vimMap,vimMark,vimMatch,vimNotFunc,vimNormal,vimProfdel,vimProfile,vimRedir,vimSet,vimSleep,vimSort,vimSyntax,vimSynColor,vimSynLink,vimThrow,vimUniq,vimUnlet,vimUnlockvar,vimUnmap,vimUserCmd,vimVimgrep,vimVimgrepadd,vimMenu,vimMenutranslate,@vim9CmdList,@vimExUserCmdList,vimLua,vimMzScheme,vimPerl,vimPython,vimPython3,vimPythonX,vimRuby,vimTcl
|
||||
syn cluster vim9CmdList contains=vim9Abstract,vim9Class,vim9Const,vim9Enum,vim9Export,vim9Final,vim9For,vim9Interface,vim9Type,vim9Var
|
||||
syn match vimCmdSep "\\\@1<!|" skipwhite nextgroup=@vimCmdList,vimSubst1,@vimFunc
|
||||
syn match vimCmdSep ":\+" skipwhite nextgroup=@vimCmdList,vimSubst1
|
||||
@ -1245,6 +1257,16 @@ syn region vimExecute
|
||||
\ contains=@vimContinue,@vimExprList
|
||||
\ transparent
|
||||
|
||||
syn region vimEval
|
||||
\ matchgroup=vimCommand
|
||||
\ start="\<ev\%[al]\>"
|
||||
\ skip=+\\|\|||\|\n\s*\%(\\\|["#]\\ \)+
|
||||
\ end="\ze|"
|
||||
\ excludenl end="$"
|
||||
\ nextgroup=vimCmdSep
|
||||
\ contains=@vimContinue,@vimExprList
|
||||
\ transparent
|
||||
|
||||
" Filter: {{{2
|
||||
" ======
|
||||
syn match vimExFilter "\<filt\%[er]\>" skipwhite nextgroup=vimExFilterBang,vimExFilterPattern
|
||||
@ -2067,7 +2089,7 @@ unlet s:interfaces
|
||||
" (following Gautam Iyer's suggestion)
|
||||
" ==========================
|
||||
syn match vimFunc contained "\<\l\w*\ze\s*(" skipwhite nextgroup=vimOperParen contains=vimFuncName
|
||||
syn match vimUserFunc contained "\.\@1<=\l\w*\ze\s*(" skipwhite nextgroup=vimOperParen contains=vimFuncName
|
||||
syn match vimUserFunc contained "\.\@1<=\l\w*\ze\s*(" skipwhite nextgroup=vimOperParen
|
||||
syn match vimUserFunc contained "\<\%([[:upper:]_]\|\%(\h\w*\.\)\+\h\)\w*\ze\s*(" skipwhite nextgroup=vimOperParen contains=vim9MethodName,vim9Super,vim9This
|
||||
syn match vimUserFunc contained "\<\%(g:\)\=\%(\h\w*#\)\+\h\w*\ze\s*(" skipwhite nextgroup=vimOperParen contains=vimVarScope
|
||||
syn match vimUserFunc contained "\%(\<[sgbwtlav]:\|<[sS][iI][dD]>\)\%(\h\w*\.\)*\h\w*\ze\s*(" skipwhite nextgroup=vimOperParen contains=vimVarScope,vimNotation
|
||||
@ -2224,6 +2246,7 @@ if !exists("skip_vim_syntax_inits")
|
||||
hi def link vimEnvvar PreProc
|
||||
hi def link vimError Error
|
||||
hi def link vimEscape Special
|
||||
hi def link vimEval vimCommand
|
||||
hi def link vimExFilter vimCommand
|
||||
hi def link vimExFilterBang vimBang
|
||||
hi def link vimExMark vimCommand
|
||||
|
||||
Reference in New Issue
Block a user