|
1 | 1 | ; Highlights query for EmmyLuaDoc |
2 | | -; 用于语法高亮的查询文件 |
3 | | - |
4 | | -; ============================================ |
5 | | -; Lua 注释前缀 (Comment Prefix) |
6 | | -; ============================================ |
7 | 2 |
|
| 3 | +; Comment Prefix |
8 | 4 | (comment_prefix) @comment |
9 | 5 |
|
10 | | -; ============================================ |
11 | | -; 注解关键字 (Annotation Keywords) |
12 | | -; ============================================ |
13 | | - |
14 | | -; 使用匿名节点匹配注解标记 |
| 6 | +; Annotation Keywords |
15 | 7 | "@class" @keyword |
| 8 | +"@interface" @keyword |
16 | 9 | "@field" @keyword |
17 | 10 | "@type" @keyword |
18 | 11 | "@param" @keyword |
19 | 12 | "@return" @keyword |
20 | 13 | "@generic" @keyword |
21 | | -"@vararg" @keyword |
22 | 14 | "@overload" @keyword |
23 | 15 | "@see" @keyword |
24 | 16 | "@alias" @keyword |
|
28 | 20 | "@version" @keyword |
29 | 21 | "@diagnostic" @keyword |
30 | 22 | "@operator" @keyword |
| 23 | +"@namespace" @keyword |
| 24 | +"@using" @keyword |
| 25 | +"@language" @keyword |
| 26 | +"@attribute" @keyword |
| 27 | +"@as" @keyword |
31 | 28 |
|
32 | | -; 特殊注解节点(这些没有 @ 前缀的文本节点) |
| 29 | +; Special annotation nodes |
33 | 30 | (deprecated_annotation) @keyword |
34 | 31 | (private_annotation) @keyword |
35 | 32 | (protected_annotation) @keyword |
|
38 | 35 | (async_annotation) @keyword |
39 | 36 | (nodiscard_annotation) @keyword |
40 | 37 | (meta_annotation) @keyword |
| 38 | +(readonly_annotation) @keyword |
| 39 | +(export_annotation) @keyword |
41 | 40 |
|
42 | | -; ============================================ |
43 | | -; 类型关键字 (Type Keywords) |
44 | | -; ============================================ |
| 41 | +; Visibility modifiers |
| 42 | +[ |
| 43 | + "public" |
| 44 | + "private" |
| 45 | + "protected" |
| 46 | + "package" |
| 47 | +] @keyword.modifier |
45 | 48 |
|
| 49 | +; Type keywords |
46 | 50 | [ |
47 | 51 | "fun" |
| 52 | + "async" |
48 | 53 | "table" |
| 54 | + "keyof" |
| 55 | + "typeof" |
| 56 | + "extends" |
| 57 | + "in" |
| 58 | + "and" |
| 59 | + "or" |
49 | 60 | ] @keyword.type |
50 | 61 |
|
51 | | -; ============================================ |
52 | | -; 基础类型 (Basic Types) |
53 | | -; ============================================ |
| 62 | +; Identifiers |
| 63 | +(identifier) @variable |
54 | 64 |
|
55 | | -((identifier) @type.builtin |
56 | | - (#match? @type.builtin "^(string|number|integer|boolean|table|function|thread|userdata|nil|any|unknown|self)$")) |
57 | | - |
58 | | -; 自定义类型 |
| 65 | +; Types |
59 | 66 | (basic_type |
60 | 67 | (identifier) @type) |
61 | 68 |
|
62 | | -; ============================================ |
63 | | -; 类定义 (Class Definitions) |
64 | | -; ============================================ |
| 69 | +; Built-in types |
| 70 | +((identifier) @type.builtin |
| 71 | + (#match? @type.builtin "^(string|number|integer|boolean|table|function|thread|userdata|nil|any|unknown|self)$")) |
65 | 72 |
|
| 73 | +; Class definitions |
66 | 74 | (class_annotation |
67 | 75 | name: (identifier) @type.definition) |
68 | 76 |
|
| 77 | +; Class parent types |
69 | 78 | (class_annotation |
70 | 79 | parent: (type_list |
71 | 80 | (type |
72 | 81 | (primary_type |
73 | 82 | (basic_type |
74 | 83 | (identifier) @type))))) |
75 | 84 |
|
76 | | -; ============================================ |
77 | | -; 字段和参数 (Fields and Parameters) |
78 | | -; ============================================ |
| 85 | +; Class modifiers |
| 86 | +(class_annotation |
| 87 | + [ |
| 88 | + "exact" |
| 89 | + "partial" |
| 90 | + "constructor" |
| 91 | + ] @keyword.modifier) |
79 | 92 |
|
| 93 | +; Fields and Parameters |
80 | 94 | (field_annotation |
81 | 95 | name: (field_name) @variable.member) |
82 | 96 |
|
83 | 97 | (param_annotation |
84 | 98 | name: (param_name) @variable.parameter) |
85 | 99 |
|
86 | | -(return_value |
87 | | - name: (identifier)? @variable.parameter) |
88 | | - |
89 | 100 | (param_def |
90 | 101 | name: (identifier) @variable.parameter) |
91 | 102 |
|
92 | | -; ============================================ |
93 | | -; 泛型 (Generics) |
94 | | -; ============================================ |
95 | | - |
| 103 | +; Generics |
96 | 104 | (generic_annotation |
97 | 105 | name: (identifier) @type.parameter) |
98 | 106 |
|
99 | 107 | (generic_type |
100 | 108 | base: (identifier) @type) |
101 | 109 |
|
102 | | -; ============================================ |
103 | | -; 别名和枚举 (Aliases and Enums) |
104 | | -; ============================================ |
| 110 | +(generic_params |
| 111 | + params: (identifier) @type.parameter) |
105 | 112 |
|
| 113 | +; Aliases and Enums |
106 | 114 | (alias_annotation |
107 | 115 | name: (identifier) @type.definition) |
108 | 116 |
|
109 | 117 | (enum_annotation |
110 | 118 | name: (identifier) @type.definition) |
111 | 119 |
|
112 | | -; ============================================ |
113 | | -; 可见性修饰符 (Visibility Modifiers) |
114 | | -; ============================================ |
115 | | - |
116 | | -[ |
117 | | - "public" |
118 | | - "private" |
119 | | - "protected" |
120 | | - "package" |
121 | | -] @keyword.modifier |
122 | | - |
123 | | -; ============================================ |
124 | | -; 操作符 (Operators) |
125 | | -; ============================================ |
| 120 | +; Enum modifiers |
| 121 | +(enum_annotation |
| 122 | + "key" @keyword.modifier) |
126 | 123 |
|
| 124 | +; Operators |
127 | 125 | [ |
128 | 126 | "call" |
129 | 127 | "add" "sub" "mul" "div" "mod" "pow" |
|
132 | 130 | "eq" "lt" "le" |
133 | 131 | "unm" |
134 | 132 | "bnot" "band" "bor" "bxor" "shl" "shr" |
| 133 | + "index" |
135 | 134 | ] @operator |
136 | 135 |
|
137 | | -; ============================================ |
138 | | -; 字面量 (Literals) |
139 | | -; ============================================ |
140 | | - |
| 136 | +; Literals |
141 | 137 | (string) @string |
142 | | - |
143 | 138 | (number) @number |
144 | | - |
145 | 139 | (boolean) @boolean |
| 140 | +"nil" @constant.builtin |
| 141 | + |
| 142 | +; Template types |
| 143 | +(template_chars) @string |
| 144 | + |
| 145 | +; Text line (documentation text) |
| 146 | +(text_line) @comment |
146 | 147 |
|
147 | | -; ============================================ |
148 | | -; 标点符号 (Punctuation) |
149 | | -; ============================================ |
| 148 | +; Description |
| 149 | +(description) @comment |
150 | 150 |
|
| 151 | +; Continuation description |
| 152 | +(continuation_description) @comment |
| 153 | + |
| 154 | +; Punctuation |
151 | 155 | [ |
152 | 156 | ":" |
153 | 157 | "|" |
154 | 158 | "," |
155 | 159 | "?" |
156 | 160 | ] @punctuation.delimiter |
157 | 161 |
|
158 | | -; 类型续行中的 | |
159 | | -(type_continuation |
160 | | - "|" @punctuation.delimiter) |
161 | | - |
162 | 162 | [ |
163 | 163 | "(" |
164 | 164 | ")" |
165 | 165 | "[" |
166 | 166 | "]" |
167 | 167 | "<" |
168 | 168 | ">" |
| 169 | + "{" |
| 170 | + "}" |
169 | 171 | ] @punctuation.bracket |
170 | 172 |
|
171 | | -; ============================================ |
172 | | -; 元组类型 (Tuple Types) |
173 | | -; ============================================ |
174 | | - |
175 | | -; 元组括号 |
176 | | -(tuple_type |
177 | | - "[" @punctuation.bracket |
178 | | - "]" @punctuation.bracket) |
179 | | - |
180 | | -; 元组元素中的逗号 |
181 | | -(tuple_elements |
182 | | - "," @punctuation.delimiter) |
| 173 | +; Function type |
| 174 | +(function_type |
| 175 | + "fun" @keyword.function) |
183 | 176 |
|
184 | | -; ============================================ |
185 | | -; 引用和诊断 (References and Diagnostics) |
186 | | -; ============================================ |
| 177 | +; Table type |
| 178 | +(table_type |
| 179 | + "table" @type.builtin) |
187 | 180 |
|
188 | | -(see_annotation |
189 | | - reference: (identifier) @variable) |
| 181 | +; Table fields |
| 182 | +(table_field |
| 183 | + name: (identifier) @property) |
190 | 184 |
|
| 185 | +; Diagnostic actions |
191 | 186 | (diagnostic_annotation |
192 | 187 | action: [ |
193 | 188 | "disable" |
|
199 | 194 | (diagnostic_list |
200 | 195 | (identifier) @constant) |
201 | 196 |
|
202 | | -; ============================================ |
203 | | -; 模块名 (Module Names) |
204 | | -; ============================================ |
| 197 | +; Attributes |
| 198 | +(attribute_use_item |
| 199 | + name: (identifier) @function.macro) |
| 200 | + |
| 201 | +(attribute_annotation |
| 202 | + name: (identifier) @function.macro) |
205 | 203 |
|
| 204 | +; Module names |
206 | 205 | (module_annotation |
207 | 206 | name: (string) @module) |
208 | 207 |
|
209 | | -; ============================================ |
210 | | -; 版本 (Version) |
211 | | -; ============================================ |
212 | | - |
| 208 | +; Version |
213 | 209 | (version_annotation |
214 | 210 | version: [ |
215 | 211 | (identifier) @constant |
216 | 212 | (string) @string |
| 213 | + (version_range) @constant |
217 | 214 | ]) |
218 | 215 |
|
219 | | -; ============================================ |
220 | | -; 数组类型标记 (Array Type Markers) |
221 | | -; ============================================ |
222 | | - |
223 | | -(array_type |
224 | | - "[" @punctuation.bracket |
225 | | - "]" @punctuation.bracket) |
226 | | - |
227 | | -; ============================================ |
228 | | -; 函数类型 (Function Types) |
229 | | -; ============================================ |
230 | | - |
231 | | -(function_type |
232 | | - "fun" @keyword.function |
233 | | - ":" @punctuation.delimiter) |
234 | | - |
235 | | -; ============================================ |
236 | | -; 表类型 (Table Types) |
237 | | -; ============================================ |
238 | | - |
239 | | -(table_type |
240 | | - "table" @type.builtin) |
241 | | - |
242 | | -; 表字面量类型 (Table Literal Types) |
243 | | -(table_literal_type |
244 | | - "{" @punctuation.bracket |
245 | | - "}" @punctuation.bracket) |
246 | | - |
247 | | -; 命名字段 |
248 | | -(table_field |
249 | | - name: (identifier) @property |
250 | | - ":" @punctuation.delimiter |
251 | | - type: (type_list |
252 | | - (type |
253 | | - (primary_type |
254 | | - (basic_type |
255 | | - (identifier) @type))))) |
256 | | - |
257 | | -; 索引字段 |
258 | | -(table_field |
259 | | - "[" @punctuation.bracket |
260 | | - "]" @punctuation.bracket |
261 | | - ":" @punctuation.delimiter) |
262 | | - |
263 | | -; 表字段中的逗号 |
264 | | -(table_literal_type |
265 | | - "," @punctuation.delimiter) |
266 | | - |
267 | | -; ============================================ |
268 | | -; 泛型参数 (Generic Parameters) |
269 | | -; ============================================ |
| 216 | +; See references |
| 217 | +(see_annotation |
| 218 | + reference: (identifier) @variable) |
270 | 219 |
|
271 | | -; @class 和 @alias 的泛型参数定义 |
272 | | -(generic_params |
273 | | - "<" @punctuation.bracket |
274 | | - ">" @punctuation.bracket) |
| 220 | +; Namespace |
| 221 | +(namespace_annotation |
| 222 | + name: (identifier) @namespace) |
275 | 223 |
|
276 | | -(generic_params |
277 | | - params: (identifier) @type.parameter) |
278 | | - |
279 | | -; ============================================ |
280 | | -; nil 字面量 (nil Literal) |
281 | | -; ============================================ |
| 224 | +; Using |
| 225 | +(using_annotation |
| 226 | + path: [ |
| 227 | + (identifier) @namespace |
| 228 | + (string) @string |
| 229 | + ]) |
282 | 230 |
|
283 | | -"nil" @constant.builtin |
| 231 | +; Language |
| 232 | +(language_annotation |
| 233 | + language: (identifier) @constant) |
0 commit comments