Skip to content

Commit adb703e

Browse files
dkearnschrisbra
authored andcommitted
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>
1 parent b5459ee commit adb703e

4 files changed

Lines changed: 45 additions & 6 deletions

File tree

runtime/syntax/generator/vim.vim.base

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ if s:vim9script
476476
\ skipwhite skipnl nextgroup=vim9MethodDefBody,vim9MethodDefComment,vimEnddef,vim9MethodDefReturnType,vimCommentError
477477
\ contains=vimDefParam,vim9Comment,vimFuncParamEquals
478478

479-
syn match vim9ConstructorDefName contained "\<new\w*\>"
479+
syn match vim9ConstructorDefName contained "\<_\=new\w*\>"
480480
\ nextgroup=vim9ConstructorDefParams
481481
\ contains=@vim9MethodName
482482
syn match vim9ConstructorDefParam contained "\<\%(this\.\)\=\h\w*\>"
@@ -513,14 +513,14 @@ if s:vim9script
513513
if !exists("g:vimsyn_noerror") && !exists("g:vimsyn_novimfunctionerror")
514514
syn match vim9MethodNameError contained "\<[a-z0-9]\i\>"
515515
endif
516-
syn match vim9MethodName contained "\<new\w*\>"
516+
syn match vim9MethodName contained "\<_\=new\w*\>"
517517
syn keyword vim9MethodName contained empty len string
518518

519519
syn cluster vim9MethodName contains=vim9MethodName,vim9MethodNameError
520520

521521
if exists("g:vimsyn_folding") && g:vimsyn_folding =~# 'f'
522522
syn region vim9MethodDefFold contained start="\%(^\s*\%(:\=static\s\+\)\=\)\@16<=:\=def\s\+\h\i*(" end="^\s*:\=enddef\>" contains=vim9MethodDef fold keepend extend transparent
523-
syn region vim9MethodDefFold contained start="^\s*:\=def\s\+new\i*(" end="^\s*:\=enddef\>" contains=vim9MethodDef fold keepend extend transparent
523+
syn region vim9MethodDefFold contained start="^\s*:\=def\s\+_\=new\i*(" end="^\s*:\=enddef\>" contains=vim9MethodDef fold keepend extend transparent
524524
endif
525525

526526
syn cluster vim9MethodDef contains=vim9MethodDef,vim9MethodDefFold
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
>v+0#af5f00255#ffffff0|i|m|9|s|c|r|i|p|t| +0#0000000&@64
2+
@75
3+
|#+0#0000e05&| |V|i|m|9| |c|o|n|s|t|r|u|c|t|o|r| +0#0000000&@56
4+
@75
5+
@75
6+
|c+0#af5f00255&|l|a|s@1| +0#0000000&|A| @67
7+
@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
8+
@2|v+0#af5f00255&|a|r| +0#0000000&|s|t|r|:| |s+0#00e0003&|t|r|i|n|g| +0#0000000&@57
9+
@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
10+
@4|t+0#00e0e07&|h|i|s|.+0#af5f00255&|s+0#0000000&|t|r| |=+0#af5f00255&| +0#0000000&|s|t|r| @56
11+
@2|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@66
12+
@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
13+
@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
14+
@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
15+
@4|e+0#af5f00255&|n|d|i|f| +0#0000000&@65
16+
@4|r+0#af5f00255&|e|t|u|r|n| +0#0000000&|_|i|n|s|t|a|n|c|e| @54
17+
@2|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@66
18+
|e+0#af5f00255&|n|d|c|l|a|s@1| +0#0000000&@66
19+
@75
20+
@57|1|,|1| @10|A|l@1|
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
vim9script
2+
3+
# Vim9 constructor
4+
5+
6+
class A
7+
static var _instance: A
8+
var str: string
9+
def _new(str: string)
10+
this.str = str
11+
enddef
12+
static def GetInstance(str: string): A
13+
if _instance == null
14+
_instance = A._new(str)
15+
endif
16+
return _instance
17+
enddef
18+
endclass
19+

runtime/syntax/vim.vim

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ if s:vim9script
526526
\ skipwhite skipnl nextgroup=vim9MethodDefBody,vim9MethodDefComment,vimEnddef,vim9MethodDefReturnType,vimCommentError
527527
\ contains=vimDefParam,vim9Comment,vimFuncParamEquals
528528

529-
syn match vim9ConstructorDefName contained "\<new\w*\>"
529+
syn match vim9ConstructorDefName contained "\<_\=new\w*\>"
530530
\ nextgroup=vim9ConstructorDefParams
531531
\ contains=@vim9MethodName
532532
syn match vim9ConstructorDefParam contained "\<\%(this\.\)\=\h\w*\>"
@@ -563,14 +563,14 @@ if s:vim9script
563563
if !exists("g:vimsyn_noerror") && !exists("g:vimsyn_novimfunctionerror")
564564
syn match vim9MethodNameError contained "\<[a-z0-9]\i\>"
565565
endif
566-
syn match vim9MethodName contained "\<new\w*\>"
566+
syn match vim9MethodName contained "\<_\=new\w*\>"
567567
syn keyword vim9MethodName contained empty len string
568568

569569
syn cluster vim9MethodName contains=vim9MethodName,vim9MethodNameError
570570

571571
if exists("g:vimsyn_folding") && g:vimsyn_folding =~# 'f'
572572
syn region vim9MethodDefFold contained start="\%(^\s*\%(:\=static\s\+\)\=\)\@16<=:\=def\s\+\h\i*(" end="^\s*:\=enddef\>" contains=vim9MethodDef fold keepend extend transparent
573-
syn region vim9MethodDefFold contained start="^\s*:\=def\s\+new\i*(" end="^\s*:\=enddef\>" contains=vim9MethodDef fold keepend extend transparent
573+
syn region vim9MethodDefFold contained start="^\s*:\=def\s\+_\=new\i*(" end="^\s*:\=enddef\>" contains=vim9MethodDef fold keepend extend transparent
574574
endif
575575

576576
syn cluster vim9MethodDef contains=vim9MethodDef,vim9MethodDefFold

0 commit comments

Comments
 (0)