Skip to content

Commit fcf8d15

Browse files
committed
update highlight
1 parent 8e4c665 commit fcf8d15

File tree

3 files changed

+104
-155
lines changed

3 files changed

+104
-155
lines changed

extension.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ repository = "https://github.com/tree-sitter-grammars/tree-sitter-lua"
2222
commit = "d76023017f7485eae629cb60d406c7a1ca0f40c9"
2323
[grammars.emmyluadoc]
2424
repository = "https://github.com/EmmyLuaLs/tree-sitter-emmyluadoc"
25-
commit = "1b4dcb5b622d95e96cc6d5b91a85b82d60ad4e12"
25+
commit = "c35e457114a391bff05c65e893d4ee95d7d36835"

languages/emmylua/injections.scm

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
;; EmmyLua Doc comments injection
44
;; Inject --- comments as emmyluadoc language
55
;; The emmyluadoc grammar now supports --- prefix, so we can directly inject
6-
((comment
7-
(comment_content) @injection.content)
8-
(#match? @injection.content "^-")
6+
((comment) @injection.content
7+
(#match? @injection.content "^---")
98
(#set! injection.language "emmyluadoc"))
109

1110
;; LuaJIT FFI C code injection
Lines changed: 101 additions & 151 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,16 @@
11
; Highlights query for EmmyLuaDoc
2-
; 用于语法高亮的查询文件
3-
4-
; ============================================
5-
; Lua 注释前缀 (Comment Prefix)
6-
; ============================================
72

3+
; Comment Prefix
84
(comment_prefix) @comment
95

10-
; ============================================
11-
; 注解关键字 (Annotation Keywords)
12-
; ============================================
13-
14-
; 使用匿名节点匹配注解标记
6+
; Annotation Keywords
157
"@class" @keyword
8+
"@interface" @keyword
169
"@field" @keyword
1710
"@type" @keyword
1811
"@param" @keyword
1912
"@return" @keyword
2013
"@generic" @keyword
21-
"@vararg" @keyword
2214
"@overload" @keyword
2315
"@see" @keyword
2416
"@alias" @keyword
@@ -28,8 +20,13 @@
2820
"@version" @keyword
2921
"@diagnostic" @keyword
3022
"@operator" @keyword
23+
"@namespace" @keyword
24+
"@using" @keyword
25+
"@language" @keyword
26+
"@attribute" @keyword
27+
"@as" @keyword
3128

32-
; 特殊注解节点(这些没有 @ 前缀的文本节点)
29+
; Special annotation nodes
3330
(deprecated_annotation) @keyword
3431
(private_annotation) @keyword
3532
(protected_annotation) @keyword
@@ -38,92 +35,93 @@
3835
(async_annotation) @keyword
3936
(nodiscard_annotation) @keyword
4037
(meta_annotation) @keyword
38+
(readonly_annotation) @keyword
39+
(export_annotation) @keyword
4140

42-
; ============================================
43-
; 类型关键字 (Type Keywords)
44-
; ============================================
41+
; Visibility modifiers
42+
[
43+
"public"
44+
"private"
45+
"protected"
46+
"package"
47+
] @keyword.modifier
4548

49+
; Type keywords
4650
[
4751
"fun"
52+
"async"
4853
"table"
54+
"keyof"
55+
"typeof"
56+
"extends"
57+
"in"
58+
"and"
59+
"or"
4960
] @keyword.type
5061

51-
; ============================================
52-
; 基础类型 (Basic Types)
53-
; ============================================
62+
; Identifiers
63+
(identifier) @variable
5464

55-
((identifier) @type.builtin
56-
(#match? @type.builtin "^(string|number|integer|boolean|table|function|thread|userdata|nil|any|unknown|self)$"))
57-
58-
; 自定义类型
65+
; Types
5966
(basic_type
6067
(identifier) @type)
6168

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)$"))
6572

73+
; Class definitions
6674
(class_annotation
6775
name: (identifier) @type.definition)
6876

77+
; Class parent types
6978
(class_annotation
7079
parent: (type_list
7180
(type
7281
(primary_type
7382
(basic_type
7483
(identifier) @type)))))
7584

76-
; ============================================
77-
; 字段和参数 (Fields and Parameters)
78-
; ============================================
85+
; Class modifiers
86+
(class_annotation
87+
[
88+
"exact"
89+
"partial"
90+
"constructor"
91+
] @keyword.modifier)
7992

93+
; Fields and Parameters
8094
(field_annotation
8195
name: (field_name) @variable.member)
8296

8397
(param_annotation
8498
name: (param_name) @variable.parameter)
8599

86-
(return_value
87-
name: (identifier)? @variable.parameter)
88-
89100
(param_def
90101
name: (identifier) @variable.parameter)
91102

92-
; ============================================
93-
; 泛型 (Generics)
94-
; ============================================
95-
103+
; Generics
96104
(generic_annotation
97105
name: (identifier) @type.parameter)
98106

99107
(generic_type
100108
base: (identifier) @type)
101109

102-
; ============================================
103-
; 别名和枚举 (Aliases and Enums)
104-
; ============================================
110+
(generic_params
111+
params: (identifier) @type.parameter)
105112

113+
; Aliases and Enums
106114
(alias_annotation
107115
name: (identifier) @type.definition)
108116

109117
(enum_annotation
110118
name: (identifier) @type.definition)
111119

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)
126123

124+
; Operators
127125
[
128126
"call"
129127
"add" "sub" "mul" "div" "mod" "pow"
@@ -132,62 +130,59 @@
132130
"eq" "lt" "le"
133131
"unm"
134132
"bnot" "band" "bor" "bxor" "shl" "shr"
133+
"index"
135134
] @operator
136135

137-
; ============================================
138-
; 字面量 (Literals)
139-
; ============================================
140-
136+
; Literals
141137
(string) @string
142-
143138
(number) @number
144-
145139
(boolean) @boolean
140+
"nil" @constant.builtin
141+
142+
; Template types
143+
(template_chars) @string
144+
145+
; Text line (documentation text)
146+
(text_line) @comment
146147

147-
; ============================================
148-
; 标点符号 (Punctuation)
149-
; ============================================
148+
; Description
149+
(description) @comment
150150

151+
; Continuation description
152+
(continuation_description) @comment
153+
154+
; Punctuation
151155
[
152156
":"
153157
"|"
154158
","
155159
"?"
156160
] @punctuation.delimiter
157161

158-
; 类型续行中的 |
159-
(type_continuation
160-
"|" @punctuation.delimiter)
161-
162162
[
163163
"("
164164
")"
165165
"["
166166
"]"
167167
"<"
168168
">"
169+
"{"
170+
"}"
169171
] @punctuation.bracket
170172

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)
183176

184-
; ============================================
185-
; 引用和诊断 (References and Diagnostics)
186-
; ============================================
177+
; Table type
178+
(table_type
179+
"table" @type.builtin)
187180

188-
(see_annotation
189-
reference: (identifier) @variable)
181+
; Table fields
182+
(table_field
183+
name: (identifier) @property)
190184

185+
; Diagnostic actions
191186
(diagnostic_annotation
192187
action: [
193188
"disable"
@@ -199,85 +194,40 @@
199194
(diagnostic_list
200195
(identifier) @constant)
201196

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)
205203

204+
; Module names
206205
(module_annotation
207206
name: (string) @module)
208207

209-
; ============================================
210-
; 版本 (Version)
211-
; ============================================
212-
208+
; Version
213209
(version_annotation
214210
version: [
215211
(identifier) @constant
216212
(string) @string
213+
(version_range) @constant
217214
])
218215

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)
270219

271-
; @class@alias 的泛型参数定义
272-
(generic_params
273-
"<" @punctuation.bracket
274-
">" @punctuation.bracket)
220+
; Namespace
221+
(namespace_annotation
222+
name: (identifier) @namespace)
275223

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+
])
282230

283-
"nil" @constant.builtin
231+
; Language
232+
(language_annotation
233+
language: (identifier) @constant)

0 commit comments

Comments
 (0)