Skip to content

Commit 56ffbdf

Browse files
committed
Format Tree-sitter query files
1 parent 65ba19b commit 56ffbdf

7 files changed

Lines changed: 155 additions & 85 deletions

File tree

languages/emmyluadoc/highlights.scm

Lines changed: 49 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,72 @@
11
; Highlights query for EmmyLuaDoc
2-
32
; Comment Prefix
43
(comment_prefix) @comment
54

65
; Annotation Keywords
76
"@class" @keyword
7+
88
"@interface" @keyword
9+
910
"@field" @keyword
11+
1012
"@type" @keyword
13+
1114
"@param" @keyword
15+
1216
"@return" @keyword
17+
1318
"@generic" @keyword
19+
1420
"@overload" @keyword
21+
1522
"@see" @keyword
23+
1624
"@alias" @keyword
25+
1726
"@enum" @keyword
27+
1828
"@module" @keyword
29+
1930
"@cast" @keyword
31+
2032
"@version" @keyword
33+
2134
"@diagnostic" @keyword
35+
2236
"@operator" @keyword
37+
2338
"@namespace" @keyword
39+
2440
"@using" @keyword
41+
2542
"@language" @keyword
43+
2644
"@attribute" @keyword
45+
2746
"@as" @keyword
2847

2948
; Other/unknown annotations
3049
(tag_name) @keyword
3150

3251
; Special annotation nodes
3352
(deprecated_annotation) @keyword
53+
3454
(private_annotation) @keyword
55+
3556
(protected_annotation) @keyword
57+
3658
(public_annotation) @keyword
59+
3760
(package_annotation) @keyword
61+
3862
(async_annotation) @keyword
63+
3964
(nodiscard_annotation) @keyword
65+
4066
(meta_annotation) @keyword
67+
4168
(readonly_annotation) @keyword
69+
4270
(export_annotation) @keyword
4371

4472
; Visibility modifiers
@@ -71,7 +99,8 @@
7199

72100
; Built-in types
73101
((identifier) @type.builtin
74-
(#match? @type.builtin "^(string|number|integer|boolean|table|function|thread|userdata|nil|any|unknown|self)$"))
102+
(#match? @type.builtin
103+
"^(string|number|integer|boolean|table|function|thread|userdata|nil|any|unknown|self)$"))
75104

76105
; Class definitions
77106
(class_annotation
@@ -127,19 +156,34 @@
127156
; Operators
128157
[
129158
"call"
130-
"add" "sub" "mul" "div" "mod" "pow"
159+
"add"
160+
"sub"
161+
"mul"
162+
"div"
163+
"mod"
164+
"pow"
131165
"concat"
132166
"len"
133-
"eq" "lt" "le"
167+
"eq"
168+
"lt"
169+
"le"
134170
"unm"
135-
"bnot" "band" "bor" "bxor" "shl" "shr"
171+
"bnot"
172+
"band"
173+
"bor"
174+
"bxor"
175+
"shl"
176+
"shr"
136177
"index"
137178
] @operator
138179

139180
; Literals
140181
(string) @string
182+
141183
(number) @number
184+
142185
(boolean) @boolean
186+
143187
"nil" @constant.builtin
144188

145189
; Template types

languages/lua/brackets.scm

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1-
("[" @open "]" @close)
2-
("{" @open "}" @close)
3-
("(" @open ")" @close)
1+
("[" @open
2+
"]" @close)
3+
4+
("{" @open
5+
"}" @close)
6+
7+
("(" @open
8+
")" @close)

languages/lua/embedding.scm

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
(
2-
(comment)* @context
3-
.
4-
(function_declaration
5-
"function" @name
6-
name: (_) @name
7-
(comment)* @collapse
8-
body: (block) @collapse
9-
) @item
10-
)
1+
((comment)* @context
2+
.
3+
(function_declaration
4+
"function" @name
5+
name: (_) @name
6+
(comment)* @collapse
7+
body: (block) @collapse) @item)

languages/lua/highlights.scm

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
;; Keywords
2-
1+
; Keywords
32
[
43
"do"
54
"else"
@@ -19,12 +18,11 @@
1918
(break_statement)
2019
] @keyword
2120

22-
;; Operators
23-
21+
; Operators
2422
[
25-
"and"
26-
"not"
27-
"or"
23+
"and"
24+
"not"
25+
"or"
2826
] @keyword.operator
2927

3028
[
@@ -51,42 +49,41 @@
5149
".."
5250
] @operator
5351

54-
;; Punctuations
55-
52+
; Punctuations
5653
[
5754
";"
5855
":"
5956
","
6057
"."
6158
] @punctuation.delimiter
6259

63-
;; Brackets
64-
60+
; Brackets
6561
[
66-
"("
67-
")"
68-
"["
69-
"]"
70-
"{"
71-
"}"
62+
"("
63+
")"
64+
"["
65+
"]"
66+
"{"
67+
"}"
7268
] @punctuation.bracket
7369

74-
;; Variables
75-
70+
; Variables
7671
(identifier) @variable
7772

7873
((identifier) @variable.special
79-
(#eq? @variable.special "self"))
74+
(#eq? @variable.special "self"))
8075

8176
(variable_list
82-
attribute: (attribute
83-
(["<" ">"] @punctuation.bracket
77+
attribute: (attribute
78+
([
79+
"<"
80+
">"
81+
] @punctuation.bracket
8482
(identifier) @attribute)))
8583

86-
;; Constants
87-
84+
; Constants
8885
((identifier) @constant
89-
(#match? @constant "^[A-Z][A-Z_0-9]*$"))
86+
(#match? @constant "^[A-Z][A-Z_0-9]*$"))
9087

9188
(vararg_expression) @constant
9289

@@ -97,52 +94,55 @@
9794
(true)
9895
] @boolean
9996

100-
;; Tables
97+
; Tables
98+
(field
99+
name: (identifier) @property)
101100

102-
(field name: (identifier) @property)
103-
104-
(dot_index_expression field: (identifier) @property)
101+
(dot_index_expression
102+
field: (identifier) @property)
105103

106104
(table_constructor
107-
[
108-
"{"
109-
"}"
110-
] @constructor)
105+
[
106+
"{"
107+
"}"
108+
] @constructor)
111109

112-
;; Functions
113-
114-
(parameters (identifier) @parameter)
110+
; Functions
111+
(parameters
112+
(identifier) @parameter)
115113

116114
(function_call
117115
name: [
118116
(identifier) @function
119-
(dot_index_expression field: (identifier) @function)
117+
(dot_index_expression
118+
field: (identifier) @function)
120119
])
121120

122121
(function_declaration
123122
name: [
124123
(identifier) @function.definition
125-
(dot_index_expression field: (identifier) @function.definition)
124+
(dot_index_expression
125+
field: (identifier) @function.definition)
126126
])
127127

128-
(method_index_expression method: (identifier) @function.method)
128+
(method_index_expression
129+
method: (identifier) @function.method)
129130

130131
(function_call
131132
(identifier) @function.builtin
132133
(#any-of? @function.builtin
133-
;; built-in functions in Lua 5.1
134-
"assert" "collectgarbage" "dofile" "error" "getfenv" "getmetatable" "ipairs"
135-
"load" "loadfile" "loadstring" "module" "next" "pairs" "pcall" "print"
136-
"rawequal" "rawget" "rawset" "require" "select" "setfenv" "setmetatable"
137-
"tonumber" "tostring" "type" "unpack" "xpcall"))
138-
139-
;; Others
134+
; built-in functions in Lua 5.1
135+
"assert" "collectgarbage" "dofile" "error" "getfenv" "getmetatable" "ipairs" "load" "loadfile"
136+
"loadstring" "module" "next" "pairs" "pcall" "print" "rawequal" "rawget" "rawset" "require"
137+
"select" "setfenv" "setmetatable" "tonumber" "tostring" "type" "unpack" "xpcall"))
140138

139+
; Others
141140
(comment) @comment
142141

143142
(hash_bang_line) @preproc
144143

145144
(number) @number
146145

147146
(string) @string
147+
148148
(escape_sequence) @string.escape

languages/lua/indents.scm

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,32 @@
1-
(if_statement "end" @end) @indent
2-
(do_statement "end" @end) @indent
3-
(while_statement "end" @end) @indent
4-
(for_statement "end" @end) @indent
5-
(repeat_statement "until" @end) @indent
6-
(function_declaration "end" @end) @indent
7-
(function_definition "end" @end) @indent
8-
9-
(_ "[" "]" @end) @indent
10-
(_ "{" "}" @end) @indent
11-
(_ "(" ")" @end) @indent
1+
(if_statement
2+
"end" @end) @indent
3+
4+
(do_statement
5+
"end" @end) @indent
6+
7+
(while_statement
8+
"end" @end) @indent
9+
10+
(for_statement
11+
"end" @end) @indent
12+
13+
(repeat_statement
14+
"until" @end) @indent
15+
16+
(function_declaration
17+
"end" @end) @indent
18+
19+
(function_definition
20+
"end" @end) @indent
21+
22+
(_
23+
"["
24+
"]" @end) @indent
25+
26+
(_
27+
"{"
28+
"}" @end) @indent
29+
30+
(_
31+
"("
32+
")" @end) @indent

languages/lua/injections.scm

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
1-
;; Injections for Lua code
2-
3-
;; LuaCats Doc comments injection
1+
; Injections for Lua code
2+
; LuaCats Doc comments injection
43
(((comment) @_emmyluadoc_comment
54
(#match? @_emmyluadoc_comment "^---")) @injection.content
65
(#set! injection.language "emmyluadoc"))
76

8-
;; Add support for TODO, FIXME, HACK, etc with the "comment" extension
7+
; Add support for TODO, FIXME, HACK, etc with the "comment" extension
98
((comment) @injection.content
109
(#set! injection.language "comment"))
1110

12-
;; LuaJIT FFI C code injection
11+
; LuaJIT FFI C code injection
1312
((function_call
1413
name: [
1514
(identifier) @_cdef_identifier
16-
(_ _ (identifier) @_cdef_identifier)
15+
(_
16+
_
17+
(identifier) @_cdef_identifier)
1718
]
18-
arguments: (arguments (string content: _ @injection.content
19-
(#set! injection.language "c"))))
19+
arguments: (arguments
20+
(string
21+
content: _ @injection.content
22+
(#set! injection.language "c"))))
2023
(#eq? @_cdef_identifier "cdef"))

languages/lua/outline.scm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
(function_declaration
2-
"function" @context
3-
name: (_) @name) @item
2+
"function" @context
3+
name: (_) @name) @item

0 commit comments

Comments
 (0)