comparison runtime/syntax/generator/vim.vim.base @ 34701:de9d4e6b03d0

runtime(vim): Distinguish Vim9 builtin object methods from namesake builtin functions (#14348) Commit: https://github.com/vim/vim/commit/80aabaab6636faa7cec461acc4b1fcc3a4c89376 Author: Aliaksei Budavei <32549825+zzzyxwvut@users.noreply.github.com> Date: Sun Mar 31 19:26:32 2024 +0300 runtime(vim): Distinguish Vim9 builtin object methods from namesake builtin functions (https://github.com/vim/vim/issues/14348) Currently, the overriding object method definitions are matched as vimFunctionError (:help builtin-object-methods, v9.1.0148). For example: ------------------------------------------------------------ vim9script class Test def string(): string return "Test" enddef endclass echo string(Test.new()) == Test.new().string() ------------------------------------------------------------ Instead, let's introduce a new syntax group vimMethodName and make these methods its members. In order to emphasise the link between the overriding methods and the overridden functions for highlighting, vimMethodName is linked by default to vimFuncName. Signed-off-by: Aliaksei Budavei <0x000c70@gmail.com> Signed-off-by: Doug Kearns <dougkearns@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Sun, 31 Mar 2024 18:30:03 +0200
parents af61243e5aeb
children b8b18dafd432
comparison
equal deleted inserted replaced
34700:24fb114b2f2c 34701:de9d4e6b03d0
1 " Vim syntax file 1 " Vim syntax file
2 " Language: Vim script 2 " Language: Vim script
3 " Maintainer: Hirohito Higashi <h.east.727 ATMARK gmail.com> 3 " Maintainer: Hirohito Higashi <h.east.727 ATMARK gmail.com>
4 " Doug Kearns <dougkearns@gmail.com> 4 " Doug Kearns <dougkearns@gmail.com>
5 " URL: https://github.com/vim-jp/syntax-vim-ex 5 " URL: https://github.com/vim-jp/syntax-vim-ex
6 " Last Change: 2024 Mar 28 6 " Last Change: 2024 Mar 31
7 " Former Maintainer: Charles E. Campbell 7 " Former Maintainer: Charles E. Campbell
8 8
9 " DO NOT CHANGE DIRECTLY. 9 " DO NOT CHANGE DIRECTLY.
10 " THIS FILE PARTLY GENERATED BY gen_syntax_vim.vim. 10 " THIS FILE PARTLY GENERATED BY gen_syntax_vim.vim.
11 " (Search string "GEN_SYN_VIM:" in this file) 11 " (Search string "GEN_SYN_VIM:" in this file)
247 syn match vimFunction "\<fu\%[nction]\>" skipwhite nextgroup=vimCmdSep,vimComment,vimFuncPattern contains=vimFuncKey 247 syn match vimFunction "\<fu\%[nction]\>" skipwhite nextgroup=vimCmdSep,vimComment,vimFuncPattern contains=vimFuncKey
248 syn match vimDef "\<def\>" skipwhite nextgroup=vimCmdSep,vimComment,vimFuncPattern contains=vimDefKey 248 syn match vimDef "\<def\>" skipwhite nextgroup=vimCmdSep,vimComment,vimFuncPattern contains=vimDefKey
249 249
250 syn match vimFunction "\<fu\%[nction]\>!\=\s*\%(<[sS][iI][dD]>\|[sg]:\)\=\%(\i\|[#.]\|{.\{-1,}}\)\+" contains=@vimFuncList skipwhite nextgroup=vimFuncParams 250 syn match vimFunction "\<fu\%[nction]\>!\=\s*\%(<[sS][iI][dD]>\|[sg]:\)\=\%(\i\|[#.]\|{.\{-1,}}\)\+" contains=@vimFuncList skipwhite nextgroup=vimFuncParams
251 syn match vimDef "\<def\s\+new\%(\i\|{.\{-1,}}\)\+" contains=@vimDefList nextgroup=vimDefParams 251 syn match vimDef "\<def\s\+new\%(\i\|{.\{-1,}}\)\+" contains=@vimDefList nextgroup=vimDefParams
252 syn match vimDef "\<def\>!\=\s*\%(<[sS][iI][dD]>\|[sg]:\)\=\%(\i\|[#.]\|{.\{-1,}}\)\+" contains=@vimDefList nextgroup=vimDefParams 252 syn match vimDef "\<def\>!\=\s*\%(<[sS][iI][dD]>\|[sg]:\)\=\%(\i\|[#.]\|{.\{-1,}}\)\+" contains=@vimDefList,vimMethodName nextgroup=vimDefParams
253 253
254 syn match vimFuncComment contained +".*+ skipwhite skipnl nextgroup=vimFuncBody,vimEndfunction 254 syn match vimFuncComment contained +".*+ skipwhite skipnl nextgroup=vimFuncBody,vimEndfunction
255 syn match vimDefComment contained "#.*" skipwhite skipnl nextgroup=vimDefBody,vimEnddef 255 syn match vimDefComment contained "#.*" skipwhite skipnl nextgroup=vimDefBody,vimEnddef
256 256
257 syn match vimFuncBang contained "!" 257 syn match vimFuncBang contained "!"
258 syn match vimFuncSID contained "\c<sid>" 258 syn match vimFuncSID contained "\c<sid>"
259 syn match vimFuncSID contained "\<[sg]:" 259 syn match vimFuncSID contained "\<[sg]:"
260 syn keyword vimFuncKey contained fu[nction] 260 syn keyword vimFuncKey contained fu[nction]
261 syn keyword vimDefKey contained def 261 syn keyword vimDefKey contained def
262 syn keyword vimMethodName contained empty len string
262 263
263 syn region vimFuncParams contained matchgroup=Delimiter start="(" skip=+\n\s*\\\|\n\s*"\\ + end=")" skipwhite skipnl nextgroup=vimFuncBody,vimFuncComment,vimEndfunction,vimFuncMod contains=vimFuncParam,@vimContinue 264 syn region vimFuncParams contained matchgroup=Delimiter start="(" skip=+\n\s*\\\|\n\s*"\\ + end=")" skipwhite skipnl nextgroup=vimFuncBody,vimFuncComment,vimEndfunction,vimFuncMod contains=vimFuncParam,@vimContinue
264 syn region vimDefParams contained matchgroup=Delimiter start="(" end=")" skipwhite skipnl nextgroup=vimDefBody,vimDefComment,vimEnddef,vimReturnType contains=vimDefParam,vim9Comment 265 syn region vimDefParams contained matchgroup=Delimiter start="(" end=")" skipwhite skipnl nextgroup=vimDefBody,vimDefComment,vimEnddef,vimReturnType contains=vimDefParam,vim9Comment
265 syn match vimFuncParam contained "\<\h\w*\>\|\.\.\." skipwhite nextgroup=vimFuncParamEquals 266 syn match vimFuncParam contained "\<\h\w*\>\|\.\.\." skipwhite nextgroup=vimFuncParamEquals
266 syn match vimDefParam contained "\<\h\w*\>" skipwhite nextgroup=vimParamType,vimFuncParamEquals 267 syn match vimDefParam contained "\<\h\w*\>" skipwhite nextgroup=vimParamType,vimFuncParamEquals
577 578
578 " User Function Highlighting: {{{2 579 " User Function Highlighting: {{{2
579 " (following Gautam Iyer's suggestion) 580 " (following Gautam Iyer's suggestion)
580 " ========================== 581 " ==========================
581 syn match vimFunc "\%(\%([sSgGbBwWtTlL]:\|<[sS][iI][dD]>\)\=\%(\w\+\.\)*\I[a-zA-Z0-9_.]*\)\ze\s*(" contains=vimFuncEcho,vimFuncName,vimUserFunc,vimExecute 582 syn match vimFunc "\%(\%([sSgGbBwWtTlL]:\|<[sS][iI][dD]>\)\=\%(\w\+\.\)*\I[a-zA-Z0-9_.]*\)\ze\s*(" contains=vimFuncEcho,vimFuncName,vimUserFunc,vimExecute
582 syn match vimUserFunc contained "\%(\%([sSgGbBwWtTlL]:\|<[sS][iI][dD]>\)\=\%(\w\+\.\)*\I[a-zA-Z0-9_.]*\)\|\<\u[a-zA-Z0-9.]*\>\|\<if\>" contains=vimNotation 583 syn match vimUserFunc contained "\%(\%([sSgGbBwWtTlL]:\|<[sS][iI][dD]>\)\=\%(\w\+\.\)*\I[a-zA-Z0-9_.]*\)\|\<\u[a-zA-Z0-9.]*\>\|\<if\>" contains=vimNotation,vimMethodName
583 syn keyword vimFuncEcho contained ec ech echo 584 syn keyword vimFuncEcho contained ec ech echo
584 585
585 " User Command Highlighting: {{{2 586 " User Command Highlighting: {{{2
586 syn match vimUsrCmd '^\s*\zs\u\%(\w*\)\@>\%([(#[]\|\s\+\%([-+*/%]\=\|\.\.\)=\)\@!' 587 syn match vimUsrCmd '^\s*\zs\u\%(\w*\)\@>\%([(#[]\|\s\+\%([-+*/%]\=\|\.\.\)=\)\@!'
587 588
588 " Errors And Warnings: {{{2 589 " Errors And Warnings: {{{2
589 " ==================== 590 " ====================
590 if !exists("g:vimsyn_noerror") && !exists("g:vimsyn_novimfunctionerror") 591 if !exists("g:vimsyn_noerror") && !exists("g:vimsyn_novimfunctionerror")
591 " TODO: The new-prefix exception should only apply to constructor definitions. 592 " TODO: The new-prefix exception should only apply to constructor definitions.
592 syn match vimFunctionError "\s\zs\%(new\)\@![a-z0-9]\i\{-}\ze\s*(" contained contains=vimFuncKey,vimFuncBlank 593 " TODO: The |builtin-object-methods| exception should only apply to method
594 " definitions.
595 syn match vimFunctionError "\s\zs\%(empty\|len\|new\|string\)\@![a-z0-9]\i\{-}\ze\s*(" contained contains=vimFuncKey,vimFuncBlank
593 syn match vimFunctionError "\s\zs\%(<[sS][iI][dD]>\|[sSgGbBwWtTlL]:\)\d\i\{-}\ze\s*(" contained contains=vimFuncKey,vimFuncBlank 596 syn match vimFunctionError "\s\zs\%(<[sS][iI][dD]>\|[sSgGbBwWtTlL]:\)\d\i\{-}\ze\s*(" contained contains=vimFuncKey,vimFuncBlank
594 syn match vimElseIfErr "\<else\s\+if\>" 597 syn match vimElseIfErr "\<else\s\+if\>"
595 syn match vimBufnrWarn /\<bufnr\s*(\s*["']\.['"]\s*)/ 598 syn match vimBufnrWarn /\<bufnr\s*(\s*["']\.['"]\s*)/
596 endif 599 endif
597 600
1089 hi def link vimMenu vimCommand 1092 hi def link vimMenu vimCommand
1090 hi def link vimMenuNotation vimNotation 1093 hi def link vimMenuNotation vimNotation
1091 hi def link vimMenuPriority Number 1094 hi def link vimMenuPriority Number
1092 hi def link vimMenuStatus Special 1095 hi def link vimMenuStatus Special
1093 hi def link vimMenutranslateComment vimComment 1096 hi def link vimMenutranslateComment vimComment
1097 hi def link vimMethodName vimFuncName
1094 hi def link vimMtchComment vimComment 1098 hi def link vimMtchComment vimComment
1095 hi def link vimNorm vimCommand 1099 hi def link vimNorm vimCommand
1096 hi def link vimNotation Special 1100 hi def link vimNotation Special
1097 hi def link vimNotFunc vimCommand 1101 hi def link vimNotFunc vimCommand
1098 hi def link vimNotPatSep vimString 1102 hi def link vimNotPatSep vimString