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 <dougkearns@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
ec0229414b
commit
818c641b6f
70
runtime/syntax/testdir/input/vim9_ex_class_fold.vim
Normal file
70
runtime/syntax/testdir/input/vim9_ex_class_fold.vim
Normal file
@ -0,0 +1,70 @@
|
||||
vim9script
|
||||
# Vim9 :class command
|
||||
# VIM_TEST_SETUP let g:vimsyn_folding = 'cf'
|
||||
# VIM_TEST_SETUP setl fdc=2 fdl=99 fdm=syntax
|
||||
|
||||
interface Interface1
|
||||
endinterface
|
||||
interface Interface2
|
||||
endinterface
|
||||
|
||||
class Class1
|
||||
endclass
|
||||
|
||||
export class Class2
|
||||
endclass
|
||||
|
||||
abstract class Class3
|
||||
endclass
|
||||
|
||||
export abstract class Class4
|
||||
endclass
|
||||
|
||||
class Class5 extends Class1
|
||||
endclass
|
||||
|
||||
export class Class6 extends Class1
|
||||
endclass
|
||||
|
||||
class Class7 implements Interface1, Interface2
|
||||
endclass
|
||||
|
||||
export class Class8 implements Interface1, Interface2
|
||||
endclass
|
||||
|
||||
class Class9
|
||||
def new()
|
||||
enddef
|
||||
def Method1(): void
|
||||
def Nested1(): void
|
||||
def Nested2(): void
|
||||
enddef
|
||||
enddef
|
||||
enddef
|
||||
def _Method2(): void
|
||||
enddef
|
||||
static def Method3(): void
|
||||
enddef
|
||||
endclass
|
||||
|
||||
abstract class Class10
|
||||
abstract def Method1(): void
|
||||
abstract def string(): string
|
||||
endclass
|
||||
|
||||
|
||||
# Issue: #14393
|
||||
|
||||
interface Testable
|
||||
def SetUp()
|
||||
def TearDown()
|
||||
endinterface
|
||||
|
||||
abstract class TestTemplate implements Testable
|
||||
var failed: number
|
||||
var passed: number
|
||||
|
||||
abstract def SetUp()
|
||||
abstract def TearDown()
|
||||
endclass
|
||||
|
||||
@ -93,7 +93,6 @@ vim9script
|
||||
:checktime
|
||||
:chistory
|
||||
:class
|
||||
:class
|
||||
:clast
|
||||
:clearjumps
|
||||
:clist
|
||||
@ -172,7 +171,6 @@ vim9script
|
||||
:elseif
|
||||
:emenu
|
||||
:endclass
|
||||
:endclass
|
||||
:enddef
|
||||
:endenum
|
||||
:endfor
|
||||
@ -385,8 +383,6 @@ vim9script
|
||||
:ptprevious
|
||||
:ptrewind
|
||||
:ptselect
|
||||
:public
|
||||
:public
|
||||
:put
|
||||
:pwd
|
||||
:py3
|
||||
@ -479,8 +475,6 @@ vim9script
|
||||
:startgreplace
|
||||
:startinsert
|
||||
:startreplace
|
||||
:static
|
||||
:static
|
||||
:stjump
|
||||
:stop
|
||||
:stopinsert
|
||||
@ -681,7 +675,6 @@ Foo() | checkpath
|
||||
Foo() | checktime
|
||||
Foo() | chistory
|
||||
Foo() | class
|
||||
Foo() | class
|
||||
Foo() | clast
|
||||
Foo() | clearjumps
|
||||
Foo() | clist
|
||||
@ -760,7 +753,6 @@ Foo() | else
|
||||
Foo() | elseif
|
||||
Foo() | emenu
|
||||
Foo() | endclass
|
||||
Foo() | endclass
|
||||
Foo() | enddef
|
||||
Foo() | endenum
|
||||
Foo() | endfor
|
||||
@ -972,8 +964,6 @@ Foo() | ptNext
|
||||
Foo() | ptprevious
|
||||
Foo() | ptrewind
|
||||
Foo() | ptselect
|
||||
Foo() | public
|
||||
Foo() | public
|
||||
Foo() | put
|
||||
Foo() | pwd
|
||||
Foo() | py3
|
||||
@ -1066,8 +1056,6 @@ Foo() | stag
|
||||
Foo() | startgreplace
|
||||
Foo() | startinsert
|
||||
Foo() | startreplace
|
||||
Foo() | static
|
||||
Foo() | static
|
||||
Foo() | stjump
|
||||
Foo() | stop
|
||||
Foo() | stopinsert
|
||||
|
||||
39
runtime/syntax/testdir/input/vim9_ex_enum_fold.vim
Normal file
39
runtime/syntax/testdir/input/vim9_ex_enum_fold.vim
Normal file
@ -0,0 +1,39 @@
|
||||
vim9script
|
||||
# Vim :enum command
|
||||
# VIM_TEST_SETUP let g:vimsyn_folding = 'ef'
|
||||
# VIM_TEST_SETUP setl fdc=2 fdl=99 fdm=syntax
|
||||
|
||||
interface Interface1
|
||||
endinterface
|
||||
interface Interface2
|
||||
endinterface
|
||||
|
||||
enum Enum1
|
||||
endenum
|
||||
|
||||
export enum Enum2
|
||||
endenum
|
||||
|
||||
enum Enum3
|
||||
Value1,
|
||||
Value2,
|
||||
Value3
|
||||
endenum
|
||||
|
||||
enum Enum4
|
||||
Value1,
|
||||
Value2,
|
||||
Value3
|
||||
def Method1()
|
||||
enddef
|
||||
endenum
|
||||
|
||||
enum Enum5 implements Interface1, Interface2
|
||||
Value1,
|
||||
Value2,
|
||||
Value3
|
||||
def Method1()
|
||||
def Nested()
|
||||
enddef
|
||||
enddef
|
||||
endenum
|
||||
36
runtime/syntax/testdir/input/vim9_ex_interface_fold.vim
Normal file
36
runtime/syntax/testdir/input/vim9_ex_interface_fold.vim
Normal file
@ -0,0 +1,36 @@
|
||||
vim9script
|
||||
# Vim :interface command
|
||||
# VIM_TEST_SETUP let g:vimsyn_folding = 'i'
|
||||
# VIM_TEST_SETUP setl fdc=2 fdl=99 fdm=syntax
|
||||
|
||||
interface Interface1
|
||||
endinterface
|
||||
|
||||
export interface Interface2
|
||||
endinterface
|
||||
|
||||
interface Interface2
|
||||
# comment
|
||||
var var1: number
|
||||
endinterface
|
||||
|
||||
interface Interface3
|
||||
# comment
|
||||
def Meth1(): number
|
||||
endinterface
|
||||
|
||||
interface Interface4
|
||||
# comment
|
||||
var var1: number
|
||||
# comment
|
||||
def Meth1(): number
|
||||
endinterface
|
||||
|
||||
interface Interface5
|
||||
# comment
|
||||
var var1: number
|
||||
var var2: number
|
||||
# comment
|
||||
def Meth1(): number
|
||||
def Meth2(): number
|
||||
endinterface
|
||||
@ -0,0 +1,113 @@
|
||||
vim9script
|
||||
# Vim9 special methods new*(), empty(), len(), string()
|
||||
|
||||
def new()
|
||||
enddef
|
||||
|
||||
def newOther()
|
||||
enddef
|
||||
|
||||
def newyetanother()
|
||||
enddef
|
||||
|
||||
def empty(): bool
|
||||
return true
|
||||
enddef
|
||||
|
||||
def len(): number
|
||||
return 0
|
||||
enddef
|
||||
|
||||
def string(): string
|
||||
return ""
|
||||
enddef
|
||||
|
||||
class A
|
||||
def new()
|
||||
def newNested()
|
||||
enddef
|
||||
def empty(): bool
|
||||
return true
|
||||
enddef
|
||||
def len(): number
|
||||
return 0
|
||||
enddef
|
||||
def string(): string
|
||||
return ""
|
||||
enddef
|
||||
enddef
|
||||
|
||||
def newOther()
|
||||
def newNested()
|
||||
enddef
|
||||
def empty(): bool
|
||||
return true
|
||||
enddef
|
||||
def len(): number
|
||||
return 0
|
||||
enddef
|
||||
def string(): string
|
||||
return ""
|
||||
enddef
|
||||
enddef
|
||||
|
||||
def newyetanother()
|
||||
def newNested()
|
||||
enddef
|
||||
def empty(): bool
|
||||
return true
|
||||
enddef
|
||||
def len(): number
|
||||
return 0
|
||||
enddef
|
||||
def string(): string
|
||||
return ""
|
||||
enddef
|
||||
enddef
|
||||
|
||||
def empty(): bool
|
||||
def newNested()
|
||||
enddef
|
||||
def empty(): bool
|
||||
return true
|
||||
enddef
|
||||
def len(): number
|
||||
return 0
|
||||
enddef
|
||||
def string(): string
|
||||
return ""
|
||||
enddef
|
||||
return true
|
||||
enddef
|
||||
|
||||
def len(): number
|
||||
def newNested()
|
||||
enddef
|
||||
def empty(): bool
|
||||
return true
|
||||
enddef
|
||||
def len(): number
|
||||
return 0
|
||||
enddef
|
||||
def string(): string
|
||||
return ""
|
||||
enddef
|
||||
return 0
|
||||
enddef
|
||||
|
||||
def string(): string
|
||||
def newNested()
|
||||
enddef
|
||||
def empty(): bool
|
||||
return true
|
||||
enddef
|
||||
def len(): number
|
||||
return 0
|
||||
enddef
|
||||
def string(): string
|
||||
return ""
|
||||
enddef
|
||||
return ""
|
||||
enddef
|
||||
endclass
|
||||
|
||||
11
runtime/syntax/testdir/input/vim9_ex_type.vim
Normal file
11
runtime/syntax/testdir/input/vim9_ex_type.vim
Normal file
@ -0,0 +1,11 @@
|
||||
vim9script
|
||||
# Vim :type command
|
||||
|
||||
type Foo = string
|
||||
type Bar = list<string>
|
||||
type Baz = Foo
|
||||
|
||||
export type Qux = Baz
|
||||
|
||||
type foo = string
|
||||
|
||||
@ -383,7 +383,6 @@
|
||||
:ptprevious
|
||||
:ptrewind
|
||||
:ptselect
|
||||
:public
|
||||
:put
|
||||
:pwd
|
||||
:py3
|
||||
@ -478,7 +477,6 @@
|
||||
:startinsert
|
||||
:startgreplace
|
||||
:startreplace
|
||||
:static
|
||||
:stopinsert
|
||||
:stjump
|
||||
:stselect
|
||||
@ -971,7 +969,6 @@ call Foo() | ptnext
|
||||
call Foo() | ptprevious
|
||||
call Foo() | ptrewind
|
||||
call Foo() | ptselect
|
||||
call Foo() | public
|
||||
call Foo() | put
|
||||
call Foo() | pwd
|
||||
call Foo() | py3
|
||||
@ -1066,7 +1063,6 @@ call Foo() | stag
|
||||
call Foo() | startinsert
|
||||
call Foo() | startgreplace
|
||||
call Foo() | startreplace
|
||||
call Foo() | static
|
||||
call Foo() | stopinsert
|
||||
call Foo() | stjump
|
||||
call Foo() | stselect
|
||||
@ -1187,8 +1183,6 @@ call Foo() | z
|
||||
|
||||
:abstract
|
||||
:class
|
||||
:defcompile
|
||||
:disassemble
|
||||
:endclass
|
||||
:endinterface
|
||||
:endenum
|
||||
@ -1203,8 +1197,6 @@ call Foo() | z
|
||||
|
||||
Foo() | abstract
|
||||
Foo() | class
|
||||
Foo() | defcompile
|
||||
Foo() | disassemble
|
||||
Foo() | endclass
|
||||
Foo() | endenum
|
||||
Foo() | endinterface
|
||||
|
||||
@ -76,7 +76,7 @@ popup! &Foo | echo "Foo"
|
||||
|
||||
" a menu item name cannot start with '.'
|
||||
|
||||
export def HistoryJumpMenu()
|
||||
def HistoryJumpMenu()
|
||||
popup.FilterMenu("Jump history", dir_hist,
|
||||
(res, _) => {
|
||||
HistoryJump(res.text)
|
||||
|
||||
Reference in New Issue
Block a user