Mercurial > vim
comparison runtime/syntax/testdir/input/vim_ex_def.vim @ 34611:1790ce961c7d
runtime(vim): Update base-syntax, improve function definition highlighting (#14203)
Commit: https://github.com/vim/vim/commit/35e6f4ca27c8115c606f265e4b09e11db01c970d
Author: dkearns <dougkearns@gmail.com>
Date: Fri Mar 22 06:41:10 2024 +1100
runtime(vim): Update base-syntax, improve function definition highlighting (https://github.com/vim/vim/issues/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>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 21 Mar 2024 20:45:04 +0100 |
parents | |
children | b8b18dafd432 |
comparison
equal
deleted
inserted
replaced
34610:b46d4877f2a2 | 34611:1790ce961c7d |
---|---|
1 " Vim :def command | |
2 | |
3 | |
4 " list | |
5 | |
6 def | |
7 def Foo | |
8 def /Foo.* | |
9 | |
10 def | echo "Foo" | |
11 def " comment | |
12 def Foo | echo "Foo" | |
13 def Foo " comment | |
14 | |
15 | |
16 " definition | |
17 | |
18 " empty definition | |
19 def Foo() | |
20 enddef | |
21 | |
22 # curly-brace names | |
23 def {"F"}oo() | |
24 enddef | |
25 | |
26 def F{"o"}o() | |
27 enddef | |
28 | |
29 def Fo{"o"}() | |
30 enddef | |
31 | |
32 def {"F"}o{"o"}() | |
33 enddef | |
34 | |
35 def {"F"}{"o"}{"o"}() | |
36 enddef | |
37 | |
38 def Foo(): number | |
39 return 42 | |
40 enddef | |
41 | |
42 # trailing whitespace | |
43 def Foo(): number | |
44 return 42 | |
45 enddef | |
46 | |
47 def Foo() # comment | |
48 enddef | |
49 | |
50 def Foo(): number # comment | |
51 return 42 | |
52 enddef | |
53 | |
54 def! Foo(): number | |
55 return 42 | |
56 enddef | |
57 | |
58 def g:Foo(): number | |
59 return 42 | |
60 enddef | |
61 | |
62 def s:Foo(): number | |
63 return 42 | |
64 enddef | |
65 | |
66 def <SID>Foo(): number | |
67 return 42 | |
68 enddef | |
69 | |
70 def foo#bar#Foo(): number | |
71 return 42 | |
72 enddef | |
73 | |
74 " same name as an Ex command | |
75 def s:ls() | |
76 enddef | |
77 | |
78 | |
79 " return types | |
80 | |
81 def Foo(): void | |
82 enddef | |
83 | |
84 def Foo(): void # comment | |
85 enddef | |
86 | |
87 def Foo(): list<dict<number>> | |
88 enddef | |
89 | |
90 def Foo(): func(dict<list<number>>, func, bool, func(number, list<number>)): bool | |
91 enddef | |
92 | |
93 | |
94 " :enddef trailing | |
95 | |
96 def Foo() | |
97 # trailing whitespace | |
98 enddef | |
99 | |
100 def Foo() | |
101 enddef | echo "Foo" | |
102 | |
103 def Foo() | |
104 enddef " comment | |
105 | |
106 | |
107 " parameters | |
108 | |
109 def Foo(x: bool, y = 42, z: string = "zed") | |
110 enddef | |
111 | |
112 def Foo( | |
113 x: bool, | |
114 y = 42, | |
115 z: string = "zed") | |
116 enddef | |
117 | |
118 | |
119 " comments | |
120 | |
121 def Foo() | |
122 # Vim9-script comment | |
123 "useless string" | |
124 enddef | |
125 |