summaryrefslogtreecommitdiffstats
path: root/runtime/syntax/testdir/input
diff options
context:
space:
mode:
authordkearns <dougkearns@gmail.com>2024-03-22 06:41:10 +1100
committerGitHub <noreply@github.com>2024-03-21 20:41:10 +0100
commit35e6f4ca27c8115c606f265e4b09e11db01c970d (patch)
tree47aa9cc4268a1cd31c8a9962462c4d7c723fbcf9 /runtime/syntax/testdir/input
parent3a6bd0c5c743bf69d2e8af4c8b3c6b2cb5f3631a (diff)
runtime(vim): Update base-syntax, improve function definition highlighting (#14203)
Improve function definition highlighting. - Match bang and function modifiers - abort etc. - Only match valid scope modifiers. - Match listing commands. - Don't match ex commands in function names. - Split function syntax groups into :func and :def subgroups. - Match Vim9-script parameter and return types. - Limit legacy-script and Vim9-script comments to :func and :def definitions, respectively. Signed-off-by: Doug Kearns <dougkearns@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
Diffstat (limited to 'runtime/syntax/testdir/input')
-rw-r--r--runtime/syntax/testdir/input/vim_ex_def.vim125
-rw-r--r--runtime/syntax/testdir/input/vim_ex_def_fold.vim126
-rw-r--r--runtime/syntax/testdir/input/vim_ex_function.vim182
-rw-r--r--runtime/syntax/testdir/input/vim_ex_function_fold.vim183
4 files changed, 616 insertions, 0 deletions
diff --git a/runtime/syntax/testdir/input/vim_ex_def.vim b/runtime/syntax/testdir/input/vim_ex_def.vim
new file mode 100644
index 0000000000..dd4ecd15a3
--- /dev/null
+++ b/runtime/syntax/testdir/input/vim_ex_def.vim
@@ -0,0 +1,125 @@
+" Vim :def command
+
+
+" list
+
+def
+def Foo
+def /Foo.*
+
+def | echo "Foo"
+def " comment
+def Foo | echo "Foo"
+def Foo " comment
+
+
+" definition
+
+" empty definition
+def Foo()
+enddef
+
+# curly-brace names
+def {"F"}oo()
+enddef
+
+def F{"o"}o()
+enddef
+
+def Fo{"o"}()
+enddef
+
+def {"F"}o{"o"}()
+enddef
+
+def {"F"}{"o"}{"o"}()
+enddef
+
+def Foo(): number
+ return 42
+enddef
+
+# trailing whitespace
+def Foo(): number
+ return 42
+enddef
+
+def Foo() # comment
+enddef
+
+def Foo(): number # comment
+ return 42
+enddef
+
+def! Foo(): number
+ return 42
+enddef
+
+def g:Foo(): number
+ return 42
+enddef
+
+def s:Foo(): number
+ return 42
+enddef
+
+def <SID>Foo(): number
+ return 42
+enddef
+
+def foo#bar#Foo(): number
+ return 42
+enddef
+
+" same name as an Ex command
+def s:ls()
+enddef
+
+
+" return types
+
+def Foo(): void
+enddef
+
+def Foo(): void # comment
+enddef
+
+def Foo(): list<dict<number>>
+enddef
+
+def Foo(): func(dict<list<number>>, func, bool, func(number, list<number>)): bool
+enddef
+
+
+" :enddef trailing
+
+def Foo()
+ # trailing whitespace
+enddef
+
+def Foo()
+enddef | echo "Foo"
+
+def Foo()
+enddef " comment
+
+
+" parameters
+
+def Foo(x: bool, y = 42, z: string = "zed")
+enddef
+
+def Foo(
+ x: bool,
+ y = 42,
+ z: string = "zed")
+enddef
+
+
+" comments
+
+def Foo()
+ # Vim9-script comment
+ "useless string"
+enddef
+
diff --git a/runtime/syntax/testdir/input/vim_ex_def_fold.vim b/runtime/syntax/testdir/input/vim_ex_def_fold.vim
new file mode 100644
index 0000000000..7ab3e3f965
--- /dev/null
+++ b/runtime/syntax/testdir/input/vim_ex_def_fold.vim
@@ -0,0 +1,126 @@
+" Vim :def command
+" VIM_TEST_SETUP let g:vimsyn_folding = "f" | set fdm=syntax
+
+
+" list
+
+def
+def Foo
+def /Foo.*
+
+def | echo "Foo"
+def " comment
+def Foo | echo "Foo"
+def Foo " comment
+
+
+" definition
+
+" empty definition
+def Foo()
+enddef
+
+# curly-brace names
+def {"F"}oo()
+enddef
+
+def F{"o"}o()
+enddef
+
+def Fo{"o"}()
+enddef
+
+def {"F"}o{"o"}()
+enddef
+
+def {"F"}{"o"}{"o"}()
+enddef
+
+def Foo(): number
+ return 42
+enddef
+
+# trailing whitespace
+def Foo(): number
+ return 42
+enddef
+
+def Foo() # comment
+enddef
+
+def Foo(): number # comment
+ return 42
+enddef
+
+def! Foo(): number
+ return 42
+enddef
+
+def g:Foo(): number
+ return 42
+enddef
+
+def s:Foo(): number
+ return 42
+enddef
+
+def <SID>Foo(): number
+ return 42
+enddef
+
+def foo#bar#Foo(): number
+ return 42
+enddef
+
+" same name as an Ex command
+def s:ls()
+enddef
+
+
+" return types
+
+def Foo(): void
+enddef
+
+def Foo(): void # comment
+enddef
+
+def Foo(): list<dict<number>>
+enddef
+
+def Foo(): func(dict<list<number>>, func, bool, func(number, list<number>)): bool
+enddef
+
+
+" :enddef trailing
+
+def Foo()
+ # trailing whitespace
+enddef
+
+def Foo()
+enddef | echo "Foo"
+
+def Foo()
+enddef " comment
+
+
+" parameters
+
+def Foo(x: bool, y = 42, z: string = "zed")
+enddef
+
+def Foo(
+ x: bool,
+ y = 42,
+ z: string = "zed")
+enddef
+
+
+" comments
+
+def Foo()
+ # Vim9-script comment
+ "useless string"
+enddef
+
diff --git a/runtime/syntax/testdir/input/vim_ex_function.vim b/runtime/syntax/testdir/input/vim_ex_function.vim
new file mode 100644
index 0000000000..38213b442d
--- /dev/null
+++ b/runtime/syntax/testdir/input/vim_ex_function.vim
@@ -0,0 +1,182 @@
+" Vim :function command
+
+
+" list
+
+function
+function Foo
+function /Foo.*
+
+function | echo "Foo"
+function " comment
+function Foo | echo "Foo"
+function Foo " comment
+
+
+" definition
+
+" empty definition
+function Foo()
+endfunction
+
+" curly-brace names
+function {"F"}oo()
+endfunction
+
+function F{"o"}o()
+endfunction
+
+function Fo{"o"}()
+endfunction
+
+function {"F"}o{"o"}()
+endfunction
+
+function {"F"}{"o"}{"o"}()
+endfunction
+
+function Foo()
+ return 42
+endfunction
+
+" trailing whitespace
+function Foo()
+ return 42
+endfunction
+
+function Foo() " comment
+ return 42
+endfunction
+
+function! Foo()
+ return 42
+endfunction
+
+function g:Foo()
+ return 42
+endfunction
+
+function s:Foo()
+ return 42
+endfunction
+
+function <SID>Foo()
+ return 42
+endfunction
+
+function foo#bar#Foo()
+ return 42
+endfunction
+
+" same name as an Ex command
+function s:ls()
+endfunction
+
+
+" modifiers
+
+function Foo() range
+endfunction
+
+function Foo() range " comment
+endfunction
+
+function Foo() range
+ return 42
+endfunction
+
+function Foo() abort
+ return 42
+endfunction
+
+function Foo() dict
+ return 42
+endfunction
+
+function Foo() closure
+ return 42
+endfunction
+
+function Foo() range abort dict closure
+ return 42
+endfunction
+
+function! Foo() range
+ return 42
+endfunction
+
+function! Foo() abort
+ return 42
+endfunction
+
+function! Foo() dict
+ return 42
+endfunction
+
+function! Foo() closure
+ return 42
+endfunction
+
+function! Foo() range abort dict closure
+ return 42
+endfunction
+
+
+" :endfunction trailing
+
+function Foo()
+ return 42
+ " trailing whitespace
+endfunction
+
+function Foo()
+ return 42
+endfunction | echo "Foo"
+
+function Foo()
+ return 42
+endfunction " comment
+
+
+" parameters
+
+function Foo(x, y, z, ...)
+ return 42
+endfunction
+
+function Foo(
+ \ x,
+ \ y,
+ \ z,
+ \ ...)
+ return 42
+endfunction
+
+function Foo(x, y = 42, z = "zed")
+ return 42
+endfunction
+
+function Foo(
+ \ x,
+ \ y = 42,
+ \ z = "zed")
+ return 42
+endfunction
+
+
+" comments
+
+function Foo()
+ " Legacy-script comment
+ # 42 " comment
+ return 42
+endfunction
+
+
+" delete function
+
+delfunction Foo
+delfunction foo.bar
+delfunction! Foo
+delfunction foo.bar
+
diff --git a/runtime/syntax/testdir/input/vim_ex_function_fold.vim b/runtime/syntax/testdir/input/vim_ex_function_fold.vim
new file mode 100644
index 0000000000..f9d9bee47c
--- /dev/null
+++ b/runtime/syntax/testdir/input/vim_ex_function_fold.vim
@@ -0,0 +1,183 @@
+" Vim :function command
+" VIM_TEST_SETUP let g:vimsyn_folding = "f" | set fdm=syntax
+
+
+" list
+
+function
+function Foo
+function /Foo.*
+
+function | echo "Foo"
+function " comment
+function Foo | echo "Foo"
+function Foo " comment
+
+
+" definition
+
+" empty definition
+function Foo()
+endfunction
+
+" curly-brace names
+function {"F"}oo()
+endfunction
+
+function F{"o"}o()
+endfunction
+
+function Fo{"o"}()
+endfunction
+
+function {"F"}o{"o"}()
+endfunction
+
+function {"F"}{"o"}{"o"}()
+endfunction
+
+function Foo()
+ return 42
+endfunction
+
+" trailing whitespace
+function Foo()
+ return 42
+endfunction
+
+function Foo() " comment
+ return 42
+endfunction
+
+function! Foo()
+ return 42
+endfunction
+
+function g:Foo()
+ return 42
+endfunction
+
+function s:Foo()
+ return 42
+endfunction
+
+function <SID>Foo()
+ return 42
+endfunction
+
+function foo#bar#Foo()
+ return 42
+endfunction
+
+" same name as an Ex command
+function s:ls()
+endfunction
+
+
+" modifiers
+
+function Foo() range
+endfunction
+
+function Foo() range " comment
+endfunction
+
+function Foo() range
+ return 42
+endfunction
+
+function Foo() abort
+ return 42
+endfunction
+
+function Foo() dict
+ return 42
+endfunction
+
+function Foo() closure
+ return 42
+endfunction
+
+function Foo() range abort dict closure
+ return 42
+endfunction
+
+function! Foo() range
+ return 42
+endfunction
+
+function! Foo() abort
+ return 42
+endfunction
+
+function! Foo() dict
+ return 42
+endfunction
+
+function! Foo() closure
+ return 42
+endfunction
+
+function! Foo() range abort dict closure
+ return 42
+endfunction
+
+
+" :endfunction trailing
+
+function Foo()
+ return 42
+ " trailing whitespace
+endfunction
+
+function Foo()
+ return 42
+endfunction | echo "Foo"
+
+function Foo()
+ return 42
+endfunction " comment
+
+
+" parameters
+
+function Foo(x, y, z, ...)
+ return 42
+endfunction
+
+function Foo(
+ \ x,
+ \ y,
+ \ z,
+ \ ...)
+ return 42
+endfunction
+
+function Foo(x, y = 42, z = "zed")
+ return 42
+endfunction
+
+function Foo(
+ \ x,
+ \ y = 42,
+ \ z = "zed")
+ return 42
+endfunction
+
+
+" comments
+
+function Foo()
+ " Legacy-script comment
+ # 42 " comment
+ return 42
+endfunction
+
+
+" delete function
+
+delfunction Foo
+delfunction foo.bar
+delfunction! Foo
+delfunction foo.bar
+