runtime(vim): Update base-syntax, match protected constructors

Support for protected constructors was added in commit 7e89800.

closes: 16618

Signed-off-by: Doug Kearns <dougkearns@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Doug Kearns
2025-03-23 16:14:20 +01:00
committed by Christian Brabandt
parent b5459ee104
commit adb703e1b9
4 changed files with 45 additions and 6 deletions

View File

@ -476,7 +476,7 @@ if s:vim9script
\ skipwhite skipnl nextgroup=vim9MethodDefBody,vim9MethodDefComment,vimEnddef,vim9MethodDefReturnType,vimCommentError
\ contains=vimDefParam,vim9Comment,vimFuncParamEquals
syn match vim9ConstructorDefName contained "\<new\w*\>"
syn match vim9ConstructorDefName contained "\<_\=new\w*\>"
\ nextgroup=vim9ConstructorDefParams
\ contains=@vim9MethodName
syn match vim9ConstructorDefParam contained "\<\%(this\.\)\=\h\w*\>"
@ -513,14 +513,14 @@ if s:vim9script
if !exists("g:vimsyn_noerror") && !exists("g:vimsyn_novimfunctionerror")
syn match vim9MethodNameError contained "\<[a-z0-9]\i\>"
endif
syn match vim9MethodName contained "\<new\w*\>"
syn match vim9MethodName contained "\<_\=new\w*\>"
syn keyword vim9MethodName contained empty len string
syn cluster vim9MethodName contains=vim9MethodName,vim9MethodNameError
if exists("g:vimsyn_folding") && g:vimsyn_folding =~# 'f'
syn region vim9MethodDefFold contained start="\%(^\s*\%(:\=static\s\+\)\=\)\@16<=:\=def\s\+\h\i*(" end="^\s*:\=enddef\>" contains=vim9MethodDef fold keepend extend transparent
syn region vim9MethodDefFold contained start="^\s*:\=def\s\+new\i*(" end="^\s*:\=enddef\>" contains=vim9MethodDef fold keepend extend transparent
syn region vim9MethodDefFold contained start="^\s*:\=def\s\+_\=new\i*(" end="^\s*:\=enddef\>" contains=vim9MethodDef fold keepend extend transparent
endif
syn cluster vim9MethodDef contains=vim9MethodDef,vim9MethodDefFold

View File

@ -0,0 +1,20 @@
>v+0#af5f00255#ffffff0|i|m|9|s|c|r|i|p|t| +0#0000000&@64
@75
|#+0#0000e05&| |V|i|m|9| |c|o|n|s|t|r|u|c|t|o|r| +0#0000000&@56
@75
@75
|c+0#af5f00255&|l|a|s@1| +0#0000000&|A| @67
@2|s+0#af5f00255&|t|a|t|i|c| +0#0000000&|v+0#af5f00255&|a|r| +0#0000000&|_|i|n|s|t|a|n|c|e|:| |A| @49
@2|v+0#af5f00255&|a|r| +0#0000000&|s|t|r|:| |s+0#00e0003&|t|r|i|n|g| +0#0000000&@57
@2|d+0#af5f00255&|e|f| +0#0000000&|_+0#00e0e07&|n|e|w|(+0#e000e06&|s+0#0000000&|t|r|:| |s+0#00e0003&|t|r|i|n|g|)+0#e000e06&| +0#0000000&@51
@4|t+0#00e0e07&|h|i|s|.+0#af5f00255&|s+0#0000000&|t|r| |=+0#af5f00255&| +0#0000000&|s|t|r| @56
@2|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@66
@2|s+0#af5f00255&|t|a|t|i|c| +0#0000000&|d+0#af5f00255&|e|f| +0#0000000&|G|e|t|I|n|s|t|a|n|c|e|(+0#e000e06&|s+0#0000000&|t|r|:| |s+0#00e0003&|t|r|i|n|g|)+0#e000e06&|:+0#0000000&| |A| @34
@4|i+0#af5f00255&|f| +0#0000000&|_|i|n|s|t|a|n|c|e| |=+0#af5f00255&@1| +0#0000000&|n+0#e000002&|u|l@1| +0#0000000&@50
@6|_|i|n|s|t|a|n|c|e| |=+0#af5f00255&| +0#0000000&|A|.|_+0#00e0e07&|n|e|w|(+0#e000e06&|s+0#0000000&|t|r|)+0#e000e06&| +0#0000000&@45
@4|e+0#af5f00255&|n|d|i|f| +0#0000000&@65
@4|r+0#af5f00255&|e|t|u|r|n| +0#0000000&|_|i|n|s|t|a|n|c|e| @54
@2|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@66
|e+0#af5f00255&|n|d|c|l|a|s@1| +0#0000000&@66
@75
@57|1|,|1| @10|A|l@1|

View File

@ -0,0 +1,19 @@
vim9script
# Vim9 constructor
class A
static var _instance: A
var str: string
def _new(str: string)
this.str = str
enddef
static def GetInstance(str: string): A
if _instance == null
_instance = A._new(str)
endif
return _instance
enddef
endclass

View File

@ -526,7 +526,7 @@ if s:vim9script
\ skipwhite skipnl nextgroup=vim9MethodDefBody,vim9MethodDefComment,vimEnddef,vim9MethodDefReturnType,vimCommentError
\ contains=vimDefParam,vim9Comment,vimFuncParamEquals
syn match vim9ConstructorDefName contained "\<new\w*\>"
syn match vim9ConstructorDefName contained "\<_\=new\w*\>"
\ nextgroup=vim9ConstructorDefParams
\ contains=@vim9MethodName
syn match vim9ConstructorDefParam contained "\<\%(this\.\)\=\h\w*\>"
@ -563,14 +563,14 @@ if s:vim9script
if !exists("g:vimsyn_noerror") && !exists("g:vimsyn_novimfunctionerror")
syn match vim9MethodNameError contained "\<[a-z0-9]\i\>"
endif
syn match vim9MethodName contained "\<new\w*\>"
syn match vim9MethodName contained "\<_\=new\w*\>"
syn keyword vim9MethodName contained empty len string
syn cluster vim9MethodName contains=vim9MethodName,vim9MethodNameError
if exists("g:vimsyn_folding") && g:vimsyn_folding =~# 'f'
syn region vim9MethodDefFold contained start="\%(^\s*\%(:\=static\s\+\)\=\)\@16<=:\=def\s\+\h\i*(" end="^\s*:\=enddef\>" contains=vim9MethodDef fold keepend extend transparent
syn region vim9MethodDefFold contained start="^\s*:\=def\s\+new\i*(" end="^\s*:\=enddef\>" contains=vim9MethodDef fold keepend extend transparent
syn region vim9MethodDefFold contained start="^\s*:\=def\s\+_\=new\i*(" end="^\s*:\=enddef\>" contains=vim9MethodDef fold keepend extend transparent
endif
syn cluster vim9MethodDef contains=vim9MethodDef,vim9MethodDefFold