runtime(vim): Update base-syntax, improve :import highlighting

- Match "autoload" as a keyword in :import commands.
- Match an expression argument for the filename.

closes: #15375

Signed-off-by: Doug Kearns <dougkearns@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Doug Kearns
2025-05-18 20:37:34 +02:00
committed by Christian Brabandt
parent 0816f17e9a
commit 7b5550fac7
21 changed files with 618 additions and 8 deletions

View File

@ -1,7 +1,7 @@
" Vim syntax file generator
" Language: Vim script
" Maintainer: Hirohito Higashi (h_east)
" Last Change: 2025 May 16
" Last Change: 2025 May 17
let s:keepcpo= &cpo
set cpo&vim
@ -293,6 +293,7 @@ function s:get_vim_command_type(cmd_name)
grepadd
helpgrep
if
import
interface
insert
let

View File

@ -2,7 +2,7 @@
" Language: Vim script
" Maintainer: Hirohito Higashi <h.east.727 ATMARK gmail.com>
" Doug Kearns <dougkearns@gmail.com>
" Last Change: 2025 May 16
" Last Change: 2025 May 17
" Former Maintainer: Charles E. Campbell
" DO NOT CHANGE DIRECTLY.
@ -233,7 +233,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,vimConst,vimDoautocmd,vimDebuggreedy,vimDef,vimDefFold,vimDelcommand,@vimEcho,vimElse,vimEnddef,vimEndfunction,vimEndif,vimExecute,vimIsCommand,vimExtCmd,vimExFilter,vimFor,vimFunction,vimFuncFold,vimGrep,vimGrepAdd,vimGlobal,vimHelpgrep,vimHighlight,vimLet,vimLoadkeymap,vimLockvar,vimMake,vimMap,vimMark,vimMatch,vimNotFunc,vimNormal,vimRedir,vimSet,vimSleep,vimSort,vimSyntax,vimThrow,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,vimConst,vimDoautocmd,vimDebuggreedy,vimDef,vimDefFold,vimDelcommand,@vimEcho,vimElse,vimEnddef,vimEndfunction,vimEndif,vimExecute,vimIsCommand,vimExtCmd,vimExFilter,vimFor,vimFunction,vimFuncFold,vimGrep,vimGrepAdd,vimGlobal,vimHelpgrep,vimHighlight,vimImport,vimLet,vimLoadkeymap,vimLockvar,vimMake,vimMap,vimMark,vimMatch,vimNotFunc,vimNormal,vimRedir,vimSet,vimSleep,vimSort,vimSyntax,vimThrow,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
@ -320,6 +320,47 @@ endif
syn keyword vimFTCmd contained filet[ype]
syn keyword vimFTOption contained detect indent off on plugin
" Import {{{2
" ======
syn keyword vimImportAutoload contained autoload skipwhite nextgroup=vimImportFilename
if s:vim9script
syn region vimImportFilename contained
\ start="\S"
\ skip=+\%#=1
"\ continuation operators at SOL
\\n\%(\s*#.*\n\)*\s*\%([[:punct:]]\+\&[^#"'(]\)
\\|
"\ continuation operators at EOL
\\%(\%([[:punct:]]\+\&[^#"')]\)\s*\%(#.*\)\=\)\@<=$
\\|
\\n\%(\s*#.*\n\)*\s*as\s
\\|
\\%(^\s*#.*\)\@<=$
\\|
\\n\s*\\\|\n\s*#\\
\+
\ matchgroup=vimCommand
\ end="\s\+\zsas\ze\s\+\h"
\ matchgroup=NONE
\ end="$"
\ skipwhite nextgroup=vimImportName
\ contains=@vim9Continue,@vimExprList,vim9Comment
\ transparent
else
syn region vimImportFilename contained
\ start="\S"
\ skip=+\n\s*\\\|\n\s*"\\ +
\ matchgroup=vimCommand
\ end="\s\+\zsas\ze\s\+\h"
\ matchgroup=NONE
\ end="$"
\ skipwhite nextgroup=vimImportName
\ contains=@vimContinue,@vimExprList
\ transparent
endif
syn match vimImportName contained "\%(\<as\s\+\)\@<=\h\w*\>" skipwhite nextgroup=@vimComment
syn match vimImport "\<imp\%[ort]\>" skipwhite nextgroup=vimImportAutoload,vimImportFilename
" Augroup : vimAugroupError removed because long augroups caused sync'ing problems. {{{2
" ======= : Trade-off: Increasing synclines with slower editing vs augroup END error checking.
syn cluster vimAugroupList contains=@vimCmdList,vimFilter,vimFunc,vimLineComment,vimSpecFile,vimOper,vimNumber,vimOperParen,@vimComment,vimString,vimSubst,vimRegister,vimCmplxRepeat,vimNotation,vimCtrlChar,vimContinue
@ -1880,7 +1921,7 @@ if exists("g:vimsyn_minlines")
endif
exe "syn sync maxlines=".s:vimsyn_maxlines
syn sync linecont "^\s\+\\"
syn sync linebreaks=1
syn sync linebreaks=2
syn sync match vimAugroupSyncA groupthere NONE "\<aug\%[roup]\>\s\+[eE][nN][dD]"
" ====================
@ -2013,6 +2054,9 @@ if !exists("skip_vim_syntax_inits")
hi def link vimHiStartStop vimHiTerm
hi def link vimHiTerm Type
hi def link vimHLGroup vimGroup
hi def link vimImport vimCommand
hi def link vimImportAutoload Special
hi def link vimImportAs vimImport
hi def link vimInsert vimString
hi def link vim9KeymapLineComment vimKeymapLineComment
hi def link vimKeymapLineComment vimComment