runtime(vim): Distinguish Vim9 constructor definitions from the :new ex command (#14050)
With the arrival of Vim9 classes, the syntax must allow for
_new_ constructors; multiple constructor definitions are
supported for a class, provided distinct suffix-names are
used. Currently, the defined constructors match either
vimCommand or vimFunctionError (for any newBar).
For example:
------------------------------------------------------------
vim9script
class Foo
def new()
enddef
def newBar()
enddef
endclass
------------------------------------------------------------
Since every constructor is required to bear a lower-cased
_new_ prefix name, it should suffice to distinguish them
from functions, and so there are no new highlight or syntax
groups introduced.
Signed-off-by: Aliaksei Budavei <0x000c70@gmail.com>
Signed-off-by: h-east <h.east.727@gmail.com>
Signed-off-by: Doug Kearns <dougkearns@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/runtime/syntax/testdir/input/vim_new.vim b/runtime/syntax/testdir/input/vim_new.vim
new file mode 100644
index 0000000..985cfd3
--- /dev/null
+++ b/runtime/syntax/testdir/input/vim_new.vim
@@ -0,0 +1,17 @@
+vim9script
+
+# Vim :new command and class constructors.
+class Test
+ def new()
+ enddef
+ def newOther()
+ enddef
+ def newyetanother()
+ enddef
+endclass
+
+Test.new()
+Test.newOther()
+Test.newyetanother()
+new
+quit