runtime(vim): Update base-syntax file, improve class, enum and interface highlighting
Commit: https://github.com/vim/vim/commit/818c641b6fac73b574a2b760213f515cee9a3c8e Author: Doug Kearns <dougkea...@gmail.com> Date: Sun Oct 6 17:00:48 2024 +0200 runtime(vim): Update base-syntax file, improve class, enum and interface highlighting - Enable folding of class, enum and interface declarations. - Highlight constructor names with the Function highlight group, like other special methods. - Mark function definitions using special method names as errors. - Highlight :type arguments. fixes: #14393#issuecomment-2042796198. closes: #13810 Signed-off-by: Doug Kearns <dougkea...@gmail.com> Signed-off-by: Christian Brabandt <c...@256bit.org> diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt index 286dcbbfb..6b7dbf908 100644 --- a/runtime/doc/syntax.txt +++ b/runtime/doc/syntax.txt @@ -1,4 +1,4 @@ -*syntax.txt* For Vim version 9.1. Last change: 2024 Oct 05 +*syntax.txt* For Vim version 9.1. Last change: 2024 Oct 06 VIM REFERENCE MANUAL by Bram Moolenaar @@ -3956,10 +3956,13 @@ mzscheme and embedded perl). Some folding is now supported with when 'foldmethod' is set to "syntax": > g:vimsyn_folding == 0 or doesn't exist: no syntax-based folding - g:vimsyn_folding =~ 'a' : augroups + g:vimsyn_folding =~ 'a' : fold augroups + g:vimsyn_folding =~ 'c' : fold Vim9 classes + g:vimsyn_folding =~ 'e' : fold Vim9 enums g:vimsyn_folding =~ 'f' : fold functions g:vimsyn_folding =~ 'h' : fold heredocs - g:vimsyn_folding =~ 'H' : fold Vim9-script legacy headers + g:vimsyn_folding =~ 'i' : fold Vim9 interfaces + g:vimsyn_folding =~ 'H' : fold Vim9 legacy headers g:vimsyn_folding =~ 'l' : fold Lua script g:vimsyn_folding =~ 'm' : fold MzScheme script g:vimsyn_folding =~ 'p' : fold Perl script diff --git a/runtime/syntax/generator/gen_syntax_vim.vim b/runtime/syntax/generator/gen_syntax_vim.vim index 222c891a3..7626f495d 100644 --- a/runtime/syntax/generator/gen_syntax_vim.vim +++ b/runtime/syntax/generator/gen_syntax_vim.vim @@ -1,7 +1,7 @@ " Vim syntax file generator " Language: Vim script " Maintainer: Hirohito Higashi (h_east) -" Last Change: 2024 Sep 14 +" Last Change: 2024 Oct 04 let s:keepcpo= &cpo set cpo&vim @@ -285,6 +285,7 @@ function! s:get_vim_command_type(cmd_name) behave call catch + class def delcommand doautoall @@ -297,13 +298,19 @@ function! s:get_vim_command_type(cmd_name) echon echowindow elseif + endclass enddef + endenum endfunction + endinterface + enum execute + export final for function if + interface insert let loadkeymap @@ -314,6 +321,7 @@ function! s:get_vim_command_type(cmd_name) new normal popup + public return set setglobal @@ -321,9 +329,12 @@ function! s:get_vim_command_type(cmd_name) sleep smagic snomagic + static substitute syntax + this throw + type unlet unmap var diff --git a/runtime/syntax/generator/vim.vim.base b/runtime/syntax/generator/vim.vim.base index 5afcedcbd..9088af103 100644 --- a/runtime/syntax/generator/vim.vim.base +++ b/runtime/syntax/generator/vim.vim.base @@ -2,7 +2,7 @@ " Language: Vim script " Maintainer: Hirohito Higashi <h.east.727 ATMARK gmail.com> " Doug Kearns <dougkea...@gmail.com> -" Last Change: 2024 Sep 16 +" Last Change: 2024 Oct 05 " Former Maintainer: Charles E. Campbell " DO NOT CHANGE DIRECTLY. @@ -81,12 +81,22 @@ syn case match 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 exists("g:vimsyn_folding") && g:vimsyn_folding =~# '[acefhiHlmpPrt]' if g:vimsyn_folding =~# 'a' com! -nargs=* VimFolda <args> fold else com! -nargs=* VimFolda <args> endif + if g:vimsyn_folding =~# 'c' + com! -nargs=* VimFoldc <args> fold + else + com! -nargs=* VimFoldc <args> + endif + if g:vimsyn_folding =~# 'e' + com! -nargs=* VimFolde <args> fold + else + com! -nargs=* VimFolde <args> + endif if g:vimsyn_folding =~# 'f' com! -nargs=* VimFoldf <args> fold else @@ -102,6 +112,11 @@ if exists("g:vimsyn_folding") && g:vimsyn_folding =~# '[afhHlmpPrt]' else com! -nargs=* VimFoldH <args> endif + if g:vimsyn_folding =~# 'i' + com! -nargs=* VimFoldi <args> fold + else + com! -nargs=* VimFoldi <args> + endif if g:vimsyn_folding =~# 'l' com! -nargs=* VimFoldl <args> fold else @@ -134,7 +149,10 @@ if exists("g:vimsyn_folding") && g:vimsyn_folding =~# '[afhHlmpPrt]' endif else com! -nargs=* VimFolda <args> + com! -nargs=* VimFoldc <args> + com! -nargs=* VimFolde <args> com! -nargs=* VimFoldf <args> + com! -nargs=* VimFoldi <args> com! -nargs=* VimFoldh <args> com! -nargs=* VimFoldH <args> com! -nargs=* VimFoldl <args> @@ -184,8 +202,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,vimCall,vimCatch,vimConst,vimDef,vimDelcommand,@vimEcho,vimEnddef,vimEndfunction,vimExecute,vimIsCommand,vimExtCmd,vimFor,vimFunction,vimFuncFold,vimGlobal,vimHighlight,vimLet,vimLoadkeymap,vimMap,vimMark,vimMatch,vimNotFunc,vimNorm,vimSet,vimSleep,vimSyntax,vimThrow,vimUnlet,vimUnmap,vimUserCmd,vimMenu,vimMenutranslate,@vim9CmdList -syn cluster vim9CmdList contains=vim9Const,vim9Final,vim9For,vim9Var +syn cluster vimCmdList contains=vimAbb,vimAddress,vimAutoCmd,vimAugroup,vimBehave,vimCall,vimCatch,vimConst,vimDef,vimDefFold,vimDelcommand,@vimEcho,vimEnddef,vimEndfunction,vimExecute,vimIsCommand,vimExtCmd,vimFor,vimFunction,vimFuncFold,vimGlobal,vimHighlight,vimLet,vimLoadkeymap,vimMap,vimMark,vimMatch,vimNotFunc,vimNorm,vimSet,vimSleep,vimSyntax,vimThrow,vimUnlet,vimUnmap,vimUserCmd,vimMenu,vimMenutranslate,@vim9CmdList +syn cluster vim9CmdList contains=vim9Class,vim9Const,vim9Enum,vim9Export,vim9Final,vim9For,vim9Interface,vim9Type,vim9Var syn match vimCmdSep "[:|]\+" skipwhite nextgroup=@vimCmdList,vimSubst1 syn match vimIsCommand "\<\%(\h\w*\|[23]mat\%[ch]\)\>" contains=vimCommand syn match vimBang contained "!" @@ -227,6 +245,12 @@ syn keyword vimThrow th[row] skipwhite nextgroup=@vimExprList syn keyword vimCatch cat[ch] skipwhite nextgroup=vimCatchPattern syn region vimCatchPattern contained matchgroup=Delimiter start="\z([!#$%&'()*+,-./:;<=>?@[\]^_`{}~]\)" skip="\\\|\\z1" end="\z1" contains=@vimSubstList oneline +" Export {{{2 +" ====== +if s:vim9script + syn keyword vim9Export export skipwhite nextgroup=vim9Abstract,vim9ClassBody,vim9Const,vim9Def,vim9EnumBody,vim9Final,vim9InterfaceBody,vim9Type,vim9Var +endif + " Filetypes {{{2 " ========= syn match vimFiletype "\<filet\%[ype]\(\s\+\I\i*\)*" skipwhite contains=vimFTCmd,vimFTOption,vimFTError @@ -271,7 +295,7 @@ endif syn cluster vimFuncList contains=vimFuncBang,vimFunctionError,vimFuncKey,vimFuncSID,Tag 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 vimFuncBodyCommon contains=@vimCmdList,vimCmplxRepeat,vimContinue,vimCtrlChar,vimDef,vimEnvvar,vimFBVar,vimFunc,vimFunction,vimLetHereDoc,vimNotation,vimNotFunc,vimNumber,vimOper,vimOperParen,vimRegister,vimSearch,vimSpecFile,vimString,vimSubst,vimFuncFold,vimDefFold syn cluster vimFuncBodyList contains=@vimFuncBodyCommon,vimComment,vimLineComment,vimFuncVar,vimInsert,vimConst,vimLet syn cluster vimDefBodyList contains=@vimFuncBodyCommon,vim9Comment,vim9LineComment,vim9Const,vim9Final,vim9Var,vim9Null,vim9Boolean,vim9For @@ -280,8 +304,7 @@ syn match vimFunction "\<fu\%[nction]\>" skipwhite nextgroup=vimCmdSep,vimCommen syn match vimDef "\<def\>" skipwhite nextgroup=vimCmdSep,vimComment,vimFuncPattern contains=vimDefKey syn match vimFunction "\<fu\%[nction]\>!\=\s*\%(<[sS][iI][dD]>\|[sg]:\)\=\%(\i\|[#.]\|{.\{-1,}}\)\+" contains=@vimFuncList skipwhite nextgroup=vimFuncParams -syn match vimDef "\<def\s\+new\%(\i\|{.\{-1,}}\)\+" contains=@vimDefList nextgroup=vimDefParams -syn match vimDef "\<def\>!\=\s*\%(<[sS][iI][dD]>\|[sg]:\)\=\%(\i\|[#.]\|{.\{-1,}}\)\+" contains=@vimDefList,vimMethodName nextgroup=vimDefParams +syn match vimDef "\<def\>!\=\s*\%(<[sS][iI][dD]>\|[sg]:\)\=\%(\i\|[#.]\|{.\{-1,}}\)\+" contains=@vimDefList nextgroup=vimDefParams syn match vimFuncComment contained +".*+ skipwhite skipempty nextgroup=vimFuncBody,vimEndfunction syn match vimDefComment contained "#.*" skipwhite skipempty nextgroup=vimDefBody,vimEnddef @@ -291,7 +314,6 @@ syn match vimFuncSID contained " -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/vim_dev/E1sxSyO-00G9w4-Rb%40256bit.org.