runtime(vim): Distinguish Vim9 builtin object methods from namesake builtin functions (#14348)
Commit:
https://github.com/vim/vim/commit/80aabaab6636faa7cec461acc4b1fcc3a4c89376
Author: Aliaksei Budavei <
32549825+...@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 <
0x00...@gmail.com>
Signed-off-by: Doug Kearns <
dougk...@gmail.com>
Signed-off-by: Christian Brabandt <
c...@256bit.org>
diff --git a/runtime/syntax/generator/vim.vim.base b/runtime/syntax/generator/vim.vim.base
index 25c67ecac..0f8ab0add 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 <
dougk...@gmail.com>
" URL:
https://github.com/vim-jp/syntax-vim-ex
-" Last Change: 2024 Mar 28
+" Last Change: 2024 Mar 31
" Former Maintainer: Charles E. Campbell
" DO NOT CHANGE DIRECTLY.
@@ -249,7 +249,7 @@ syn match vimDef "\<def\>" skipwhite nextgroup=vimCmdSep,vimComment,vimFuncPatt
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 nextgroup=vimDefParams
+syn match vimDef "\<def\>!\=\s*\%(<[sS][iI][dD]>\|[sg]:\)\=\%(\i\|[#.]\|{.\{-1,}}\)\+" contains=@vimDefList,vimMethodName nextgroup=vimDefParams
syn match vimFuncComment contained +".*+ skipwhite skipnl nextgroup=vimFuncBody,vimEndfunction
syn match vimDefComment contained "#.*" skipwhite skipnl nextgroup=vimDefBody,vimEnddef
@@ -259,6 +259,7 @@ syn match vimFuncSID contained "