summaryrefslogtreecommitdiffstats
path: root/runtime/syntax/generator
diff options
context:
space:
mode:
authorDoug Kearns <dougkearns@gmail.com>2024-07-17 19:34:14 +0200
committerChristian Brabandt <cb@256bit.org>2024-07-17 19:34:14 +0200
commitd65e58f6f930f769cae869aeedf00192a242c5cc (patch)
tree2fad1053dead05feeb8d1447c2ef25b847da770d /runtime/syntax/generator
parent30d54fdddf129e30345874867e0ca2bda2eaabfa (diff)
runtime(vim): Update base-syntax, match types in Vim9 variable declarations
Match types in Vim9 variable declarations. Match Vim9 boolean and null literals. These are not matched in all contexts yet. related: #15277 Signed-off-by: Doug Kearns <dougkearns@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
Diffstat (limited to 'runtime/syntax/generator')
-rw-r--r--runtime/syntax/generator/gen_syntax_vim.vim4
-rw-r--r--runtime/syntax/generator/vim.vim.base130
2 files changed, 78 insertions, 56 deletions
diff --git a/runtime/syntax/generator/gen_syntax_vim.vim b/runtime/syntax/generator/gen_syntax_vim.vim
index 94135da418..2361dbbbf2 100644
--- a/runtime/syntax/generator/gen_syntax_vim.vim
+++ b/runtime/syntax/generator/gen_syntax_vim.vim
@@ -299,8 +299,11 @@ function! s:get_vim_command_type(cmd_name)
enddef
endfunction
execute
+ final
+ for
function
insert
+ let
map
mapclear
match
@@ -316,6 +319,7 @@ function! s:get_vim_command_type(cmd_name)
substitute
syntax
throw
+ unlet
var
vim9script
EOL
diff --git a/runtime/syntax/generator/vim.vim.base b/runtime/syntax/generator/vim.vim.base
index 4f571a4900..66d1b87ec8 100644
--- a/runtime/syntax/generator/vim.vim.base
+++ b/runtime/syntax/generator/vim.vim.base
@@ -3,7 +3,7 @@
" Maintainer: Hirohito Higashi <h.east.727 ATMARK gmail.com>
" Doug Kearns <dougkearns@gmail.com>
" URL: https://github.com/vim-jp/syntax-vim-ex
-" Last Change: 2024 Jul 05
+" Last Change: 2024 Jul 17
" Former Maintainer: Charles E. Campbell
" DO NOT CHANGE DIRECTLY.
@@ -77,7 +77,11 @@ syn case match
"--- syntax here and above generated by mkvimvim ---
" Special Vim Highlighting (not automatic) {{{1
-" Set up folding commands for this syntax highlighting file {{{2
+" Set up commands for this syntax highlighting file {{{2
+
+com! -nargs=* Vim9 execute <q-args> s:vim9script ? "" : "contained"
+com! -nargs=* VimL execute <q-args> s:vim9script ? "contained" : ""
+
if exists("g:vimsyn_folding") && g:vimsyn_folding =~# '[afhHlmpPrt]'
if g:vimsyn_folding =~# 'a'
com! -nargs=* VimFolda <args> fold
@@ -160,6 +164,14 @@ else
let s:vimsyn_maxlines= 60
endif
+" Nulls {{{2
+" =====
+Vim9 syn keyword vim9Null null null_blob null_channel null_class null_dict null_function null_job null_list null_object null_partial null_string
+
+" Booleans {{{2
+" ========
+Vim9 syn keyword vim9Boolean true false
+
" Numbers {{{2
" =======
syn case ignore
@@ -173,7 +185,8 @@ syn match vimNumber '\%(^\|\A\)\zs#\x\{6}' skipwhite nextgroup=vimGlobal,vimSub
syn case match
" All vimCommands are contained by vimIsCommand. {{{2
-syn cluster vimCmdList contains=vimAbb,vimAddress,vimAutoCmd,vimAugroup,vimBehave,vimCatch,vimDef,@vimEcho,vimEnddef,vimEndfunction,vimExecute,vimIsCommand,vimExtCmd,vimFor,vimFunction,vimGlobal,vimHighlight,vimLet,vimMap,vimMark,vimMatch,vimNotFunc,vimNorm,vimSet,vimSleep,vimSyntax,vimThrow,vimUnlet,vimUnmap,vimUserCmd,vimMenu,vimMenutranslate
+syn cluster vimCmdList contains=vimAbb,vimAddress,vimAutoCmd,vimAugroup,vimBehave,vimCatch,vimConst,vimDef,@vimEcho,vimEnddef,vimEndfunction,vimExecute,vimIsCommand,vimExtCmd,vimFor,vimFunction,vimGlobal,vimHighlight,vimLet,vimMap,vimMark,vimMatch,vimNotFunc,vimNorm,vimSet,vimSleep,vimSyntax,vimThrow,vimUnlet,vimUnmap,vimUserCmd,vimMenu,vimMenutranslate,@vim9CmdList
+syn cluster vim9CmdList contains=vim9Const,vim9Final,vim9For,vim9Var
syn match vimCmdSep "[:|]\+" skipwhite nextgroup=@vimCmdList,vimSubst1
syn match vimIsCommand "\<\%(\h\w*\|[23]mat\%[ch]\)\>" contains=vimCommand
syn match vimVar contained "\<\h[a-zA-Z0-9#_]*\>"
@@ -184,7 +197,8 @@ syn match vimVar "\s\zs&t_k;"
syn match vimFBVar contained "\<[bwglstav]:\h[a-zA-Z0-9#_]*\>"
syn keyword vimCommand contained in
-syn cluster vimExprList contains=vimEnvvar,vimFunc,vimFuncVar,vimNumber,vimOper,vimOperParen,vimLetRegister,vimString,vimVar
+syn cluster vimExprList contains=vimEnvvar,vimFunc,vimNumber,vimOper,vimOperParen,vimLetRegister,vimString,vimVar,@vim9ExprList
+syn cluster vim9ExprList contains=vim9Boolean,vim9Null
" Insertions And Appends: insert append {{{2
" (buftype != nofile test avoids having append, change, insert show up in the command window)
@@ -238,8 +252,8 @@ syn keyword vimAugroupKey contained aug[roup] skipwhite nextgroup=vimAugroupBan
" Operators: {{{2
" =========
-syn cluster vimOperGroup contains=vimEnvvar,vimFunc,vimFuncVar,vimOper,vimOperParen,vimNumber,vimString,vimRegister,@vimContinue,vim9Comment,vimVar
-syn match vimOper "||\|&&\|[-+*/%.!]" skipwhite nextgroup=vimString,vimSpecFile
+syn cluster vimOperGroup contains=vimEnvvar,vimFunc,vimFuncVar,vimOper,vimOperParen,vimNumber,vimString,vimRegister,@vimContinue,vim9Comment,vimVar,vimBoolean,vimNull
+syn match vimOper "||\|&&\|[-+*/%.!]" skipwhite nextgroup=vimString,vimSpecFile
syn match vimOper "\%#=1\(==\|!=\|>=\|<=\|=\~\|!\~\|>\|<\|=\|!\~#\)[?#]\{0,2}" skipwhite nextgroup=vimString,vimSpecFile
syn match vimOper "\(\<is\|\<isnot\)[?#]\{0,2}\>" skipwhite nextgroup=vimString,vimSpecFile
syn region vimOperParen matchgroup=vimParenSep start="(" end=")" contains=@vimOperGroup
@@ -254,8 +268,8 @@ syn cluster vimFuncList contains=vimFuncBang,vimFunctionError,vimFuncKey,vimFunc
syn cluster vimDefList contains=vimFuncBang,vimFunctionError,vimDefKey,vimFuncSID,Tag
syn cluster vimFuncBodyCommon contains=@vimCmdList,vimCmplxRepeat,vimContinue,vimCtrlChar,vimDef,vimEnvvar,vimFBVar,vimFunc,vimFunction,vimLetHereDoc,vimNotation,vimNotFunc,vimNumber,vimOper,vimOperParen,vimRegister,vimSearch,vimSpecFile,vimString,vimSubst,vimFuncFold
-syn cluster vimFuncBodyList contains=@vimFuncBodyCommon,vimComment,vimLineComment,vimFuncVar,vimInsert
-syn cluster vimDefBodyList contains=@vimFuncBodyCommon,vim9Comment,vim9LineComment
+syn cluster vimFuncBodyList contains=@vimFuncBodyCommon,vimComment,vimLineComment,vimFuncVar,vimInsert,vimConst,vimLet
+syn cluster vimDefBodyList contains=@vimFuncBodyCommon,vim9Comment,vim9LineComment,vim9Const,vim9Final,vim9Var,vim9Null,vim9Boolean,vim9For
syn region vimFuncPattern contained matchgroup=vimOper start="/" end="$" contains=@vimSubstList
syn match vimFunction "\<fu\%[nction]\>" skipwhite nextgroup=vimCmdSep,vimComment,vimFuncPattern contains=vimFuncKey
@@ -276,7 +290,7 @@ syn keyword vimDefKey contained def
syn keyword vimMethodName contained empty len string
syn region vimFuncParams contained matchgroup=Delimiter start="(" skip=+\n\s*\\\|\n\s*"\\ + end=")" skipwhite skipnl nextgroup=vimFuncBody,vimFuncComment,vimEndfunction,vimFuncMod,vim9CommentError contains=vimFuncParam,@vimContinue
-syn region vimDefParams contained matchgroup=Delimiter start="(" end=")" skipwhite skipnl nextgroup=vimDefBody,vimDefComment,vimEnddef,vimReturnType,vimCommentError contains=vimDefParam,vim9Comment
+syn region vimDefParams contained matchgroup=Delimiter start="(" end=")" skipwhite skipnl nextgroup=vimDefBody,vimDefComment,vimEnddef,vimReturnType,vimCommentError contains=vimDefParam,vim9Comment,vimFuncParamEquals
syn match vimFuncParam contained "\<\h\w*\>\|\.\.\." skipwhite nextgroup=vimFuncParamEquals
syn match vimDefParam contained "\<\h\w*\>" skipwhite nextgroup=vimParamType,vimFuncParamEquals
@@ -300,9 +314,9 @@ syn match vimFuncBlank contained "\s\+"
" Types: {{{2
" =====
-" vimTypes : new for vim9
+
syn region vimReturnType contained start=":\s" end="$" matchgroup=vim9Comment end="\ze[#"]" skipwhite skipnl nextgroup=vimDefBody,vimDefComment,vimEnddef,vimCommentError contains=vimTypeSep transparent
-syn match vimParamType contained ":\s\+\a" skipwhite skipnl nextgroup=vimFuncParamEquals contains=vimTypeSep,@vimType
+syn match vimParamType contained ":\s" skipwhite skipnl nextgroup=@vimType contains=vimTypeSep
syn match vimTypeSep contained ":\s\@=" skipwhite nextgroup=@vimType
syn keyword vimType contained any blob bool channel float job number string void
@@ -377,35 +391,23 @@ if get(g:, "vimsyn_comment_strings", 1)
endif
if s:vim9script
- syn match vimComment excludenl +\s"[^\-:.%#=*].*$+lc=1 contains=@vimCommentGroup,vimCommentString contained
- syn match vimComment +\<endif\s\+".*$+lc=5 contains=@vimCommentGroup,vimCommentString contained
- syn match vimComment +\<else\s\+".*$+lc=4 contains=@vimCommentGroup,vimCommentString contained
- " Vim9 comments - TODO: might be highlighted while they don't work
- syn match vim9Comment excludenl +\s#[^{].*$+lc=1 contains=@vimCommentGroup,vimCommentString
- syn match vim9Comment +\<endif\s\+#[^{].*$+lc=5 contains=@vimCommentGroup,vimCommentString
- syn match vim9Comment +\<else\s\+#[^{].*$+lc=4 contains=@vimCommentGroup,vimCommentString
- " Vim9 comment inside expression
- " syn match vim9Comment +\s\zs#[^{].*$+ms=s+1 contains=@vimCommentGroup,vimCommentString
- " syn match vim9Comment +^\s*#[^{].*$+ contains=@vimCommentGroup,vimCommentString
- " syn match vim9Comment +^\s*#$+ contains=@vimCommentGroup,vimCommentString
-
syn cluster vimComment contains=vim9Comment
else
- syn match vimComment excludenl +\s"[^\-:.%#=*].*$+lc=1 contains=@vimCommentGroup,vimCommentString
- syn match vimComment +\<endif\s\+".*$+lc=5 contains=@vimCommentGroup,vimCommentString
- syn match vimComment +\<else\s\+".*$+lc=4 contains=@vimCommentGroup,vimCommentString
- " Vim9 comments - TODO: might be highlighted while they don't work
- syn match vim9Comment excludenl +\s#[^{].*$+lc=1 contains=@vimCommentGroup,vimCommentString contained
- syn match vim9Comment +\<endif\s\+#[^{].*$+lc=5 contains=@vimCommentGroup,vimCommentString contained
- syn match vim9Comment +\<else\s\+#[^{].*$+lc=4 contains=@vimCommentGroup,vimCommentString contained
- " Vim9 comment inside expression
- syn match vim9Comment +\s\zs#[^{].*$+ms=s+1 contains=@vimCommentGroup,vimCommentString contained
- syn match vim9Comment +^\s*#[^{].*$+ contains=@vimCommentGroup,vimCommentString contained
- syn match vim9Comment +^\s*#$+ contains=@vimCommentGroup,vimCommentString contained
-
syn cluster vimComment contains=vimComment
endif
+VimL syn match vimComment excludenl +\s"[^\-:.%#=*].*$+lc=1 contains=@vimCommentGroup,vimCommentString
+VimL syn match vimComment +\<endif\s\+".*$+lc=5 contains=@vimCommentGroup,vimCommentString
+VimL syn match vimComment +\<else\s\+".*$+lc=4 contains=@vimCommentGroup,vimCommentString
+" Vim9 comments - TODO: might be highlighted while they don't work
+Vim9 syn match vim9Comment excludenl +\s#[^{].*$+lc=1 contains=@vimCommentGroup,vimCommentString
+Vim9 syn match vim9Comment +\<endif\s\+#[^{].*$+lc=5 contains=@vimCommentGroup,vimCommentString
+Vim9 syn match vim9Comment +\<else\s\+#[^{].*$+lc=4 contains=@vimCommentGroup,vimCommentString
+" Vim9 comment inside expression
+Vim9 syn match vim9Comment +\s\zs#[^{].*$+ms=s+1 contains=@vimCommentGroup,vimCommentString contained
+Vim9 syn match vim9Comment +^\s*#[^{].*$+ contains=@vimCommentGroup,vimCommentString contained
+Vim9 syn match vim9Comment +^\s*#$+ contains=@vimCommentGroup,vimCommentString contained
+
syn match vim9CommentError contained "#.*"
syn match vimCommentError contained +".*+
@@ -505,22 +507,32 @@ syn region vimSetString contained start=+="+hs=s+1 skip=+\\\\\|\\"+ end=+"+ co
syn match vimSetSep contained "[,:]"
syn match vimSetMod contained "&vim\=\|[!&?<]\|all&"
-" Let And Var: {{{2
-" ===========
-syn keyword vimLet let skipwhite nextgroup=vimVar,vimFuncVar,vimLetHereDoc,vimLetRegister,vimVarList
-syn keyword vimConst cons[t] skipwhite nextgroup=vimVar,vimLetHereDoc,vimVarList
-syn region vimVarList contained start="\[" end="]" contains=vimVar,vimContinue
+" Variable Declarations: {{{2
+" =====================
+VimL syn keyword vimLet let skipwhite nextgroup=vimVar,vimFuncVar,vimLetRegister,vimVarList
+VimL syn keyword vimConst cons[t] skipwhite nextgroup=vimVar,vimVarList
+syn region vimVarList contained start="\[" end="]" contains=vimVar,@vimContinue
-syn keyword vimUnlet unl[et] skipwhite nextgroup=vimUnletBang,vimUnletVars
+VimL syn keyword vimUnlet unl[et] skipwhite nextgroup=vimUnletBang,vimUnletVars
syn match vimUnletBang contained "!" skipwhite nextgroup=vimUnletVars
syn region vimUnletVars contained start="$\I\|\h" skip="\n\s*\\" end="$" end="|" contains=vimVar,vimEnvvar,vimContinue,vimString,vimNumber
VimFoldh syn region vimLetHereDoc matchgroup=vimLetHereDocStart start='=<<\s*\%(trim\s\+\%(eval\s\+\)\=\|eval\s\+\%(trim\s\+\)\=\)\=\z(\L\S*\)' matchgroup=vimLetHereDocStop end='^\s*\z1\s*$' extend
-syn keyword vimLet var skipwhite nextgroup=vimVar,vimFuncVar,vimLetHereDoc
+
+Vim9 syn keyword vim9Const const skipwhite nextgroup=vim9Variable,vim9VariableList
+Vim9 syn keyword vim9Final final skipwhite nextgroup=vim9Variable,vim9VariableList
+Vim9 syn keyword vim9Var var skipwhite nextgroup=vim9Variable,vim9VariableList
+
+syn match vim9Variable contained "\<\h\w*\>" skipwhite nextgroup=vimTypeSep,vimLetHereDoc
+syn region vim9VariableList contained start="\[" end="]" contains=vim9Variable,@vimContinue
" For: {{{2
" ===
-syn keyword vimFor for skipwhite nextgroup=vimVar,vimVarList
+if s:vim9script
+ syn keyword vim9For for skipwhite nextgroup=vim9Variable,vim9VariableList
+else
+ syn keyword vimFor for skipwhite nextgroup=vimVar,vimVarList
+endif
" Abbreviations: {{{2
" =============
@@ -834,13 +846,9 @@ syn match vimCtrlChar "[- -]"
" Beginners - Patterns that involve ^ {{{2
" =========
-if s:vim9script
- syn region vim9LineComment start=+^[ \t:]*\zs#.*$+ skip=+\n\s*\\\|\n\s*#\\ + end="$" contains=@vimCommentGroup,vimCommentString,vim9CommentTitle
- syn region vimLineComment start=+^[ \t:]*\zs".*$+ skip=+\n\s*\\\|\n\s*"\\ + end="$" contains=@vimCommentGroup,vimCommentString,vimCommentTitle contained
-else
- syn region vimLineComment start=+^[ \t:]*\zs".*$+ skip=+\n\s*\\\|\n\s*"\\ + end="$" contains=@vimCommentGroup,vimCommentString,vimCommentTitle
- syn region vim9LineComment start=+^[ \t:]*\zs#.*$+ skip=+\n\s*\\\|\n\s*#\\ + end="$" contains=@vimCommentGroup,vimCommentString,vim9CommentTitle contained
-endif
+Vim9 syn region vim9LineComment start=+^[ \t:]*\zs#.*$+ skip=+\n\s*\\\|\n\s*#\\ + end="$" contains=@vimCommentGroup,vimCommentString,vim9CommentTitle
+VimL syn region vimLineComment start=+^[ \t:]*\zs".*$+ skip=+\n\s*\\\|\n\s*"\\ + end="$" contains=@vimCommentGroup,vimCommentString,vimCommentTitle
+
syn match vimCommentTitle '"\s*\%([sS]:\|\h\w*#\)\=\u\w*\(\s\+\u\w*\)*:'hs=s+1 contained contains=vimCommentTitleLeader,vimTodo,@vimCommentGroup
syn match vim9CommentTitle '#\s*\%([sS]:\|\h\w*#\)\=\u\w*\(\s\+\u\w*\)*:'hs=s+1 contained contains=vim9CommentTitleLeader,vimTodo,@vimCommentGroup
@@ -1083,7 +1091,6 @@ if !exists("skip_vim_syntax_inits")
hi def link vimBufnrWarn vimWarn
endif
- hi def link vim9Vim9ScriptArg Special
hi def link vimAbb vimCommand
hi def link vimAddress vimMark
hi def link vimAugroupBang vimBang
@@ -1102,11 +1109,8 @@ if !exists("skip_vim_syntax_inits")
hi def link vimCommand Statement
hi def link vimComment Comment
hi def link vimCommentError vimError
- hi def link vim9Comment Comment
- hi def link vim9CommentError vimError
hi def link vimCommentString vimString
hi def link vimCommentTitle PreProc
- hi def link vim9CommentTitle PreProc
hi def link vimCondHL vimCommand
hi def link vimConst vimCommand
hi def link vimContinue Special
@@ -1173,7 +1177,6 @@ if !exists("skip_vim_syntax_inits")
hi def link vimLetHereDocStop Special
hi def link vimLetRegister Special
hi def link vimLineComment vimComment
- hi def link vim9LineComment vimComment
hi def link vimMapBang vimBang
hi def link vimMapModKey vimFuncSID
hi def link vimMapMod vimBracket
@@ -1219,7 +1222,6 @@ if !exists("skip_vim_syntax_inits")
hi def link vimSetMod vimOption
hi def link vimSetSep Statement
hi def link vimSetString vimString
- hi def link vim9Vim9Script vimCommand
hi def link vimShebang PreProc
hi def link vimSleep vimCommand
hi def link vimSleepArg Constant
@@ -1280,6 +1282,20 @@ if !exists("skip_vim_syntax_inits")
hi def link vimUserFunc Normal
hi def link vimVar Identifier
hi def link vimWarn WarningMsg
+
+ hi def link vim9Boolean Boolean
+ hi def link vim9Comment Comment
+ hi def link vim9CommentError vimError
+ hi def link vim9CommentTitle PreProc
+ hi def link vim9Const vimCommand
+ hi def link vim9Final vimCommand
+ hi def link vim9For vimCommand
+ hi def link vim9LineComment vimComment
+ hi def link vim9Null Constant
+ hi def link vim9Var vimCommand
+ hi def link vim9Variable vimVar
+ hi def link vim9Vim9Script vimCommand
+ hi def link vim9Vim9ScriptArg Special
endif
" Current Syntax Variable: {{{2
@@ -1287,6 +1303,8 @@ let b:current_syntax = "vim"
" ---------------------------------------------------------------------
" Cleanup: {{{1
+delc Vim9
+delc VimL
delc VimFolda
delc VimFoldf
delc VimFoldh