vim/runtime/syntax/testdir/input/vim9_super_this_keywords.vim
Doug Kearns 1aa287e048
runtime(vim): Update base-syntax, improve variable matching
- Match variables after operators, including line continuations.
- Match option variables without leading whitespace.
- Explicitly match expression subscripts.
- Match Vim9 variables in LHS of assignments and method calls.
- Match option variables (&option) with a dedicated syntax group like
  environment variables.
- Match list literals, fixes: #5830
- Match :{un}lockvar arguments.
- Match registers and environment variables in :let unpack lists.
- Match lambda expressions
- Match Vim9 scope blocks
- Match variables in :for subject
- Highlight user variables with Normal
- Improve this/super keyword matching, fixes: #15970

closes: #16476

Signed-off-by: Doug Kearns <dougkearns@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2025-02-10 22:00:27 +01:00

87 lines
1.5 KiB
VimL

vim9script
# Vim9 this and super keywords
# VIM_TEST_SETUP hi link vim9This Todo
# VIM_TEST_SETUP hi link vim9Super Todo
def Echo(...args: list<any>)
echo args
enddef
class Foo
var x: number = 42
var y: number = this.x + 41
var z: number = this.x + this.y
def new()
echo this.x this.y this.z
enddef
def newXY(this.x, this.y, this.z)
enddef
def Def1(arg = this.x)
this.y = arg
this.z += arg
enddef
def Def2(arg = (this.x + this.y + this.z))
Echo(this, this.x, this.y, this.z)
this->Echo(this.x, this.y, this.z)
enddef
def Def3(): Foo
return this
enddef
def Def4(arg: Foo = this): Foo
return arg
enddef
endclass
class Bar extends Foo
def Def1()
super.Def1()
enddef
def Def2()
var a = super.x * super.y * super.z
var b = [super.x, super.y, super.z]
var c = {super: super.x, this: super.y, true: super.z}
var d = {super: c, this: c}
echo c.super
echo c.this
echo d.super.this
echo d.this.super
echo a b c
enddef
def Def5()
var a = this.x * this.y
var b = (this.x * this.y)
var c = [this.x, this.y]
var d = {super: this.x, this: this.y}
echo a b c d
enddef
def Def6()
var x = this#super#x
var y = super#this#y
this#super#Func()
super#this#Func()
enddef
def Def7(arg = super.Def3())
echo arg
enddef
def Def8(): number
var F = () => this.x
var G = () => super.x
return F() + G()
enddef
endclass
defcompile Foo
defcompile Bar