Skip to content

Commit 86ef358

Browse files
committed
Copy queries
1 parent 6b819dc commit 86ef358

File tree

3 files changed

+181
-106
lines changed

3 files changed

+181
-106
lines changed

queries/highlights.scm

Lines changed: 144 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
11
; CREDITS @stumash (stuart.mashaal@gmail.com)
2-
3-
(field_expression field: (identifier) @property)
4-
(field_expression value: (identifier) @type
5-
(#match? @type "^[A-Z]"))
6-
7-
(type_identifier) @type
8-
92
(class_definition
103
name: (identifier) @type)
114

@@ -24,23 +17,26 @@
2417
(simple_enum_case
2518
name: (identifier) @type)
2619

27-
;; variables
28-
20+
; variables
2921
(class_parameter
30-
name: (identifier) @parameter)
22+
name: (identifier) @variable.parameter)
3123

32-
(self_type (identifier) @parameter)
24+
(self_type
25+
(identifier) @variable.parameter)
3326

34-
(interpolation (identifier) @none)
35-
(interpolation (block) @none)
27+
(interpolation
28+
(identifier) @none)
3629

37-
;; types
30+
(interpolation
31+
(block) @none)
3832

33+
; types
3934
(type_definition
4035
name: (type_identifier) @type.definition)
4136

42-
;; val/var definitions/declarations
37+
(type_identifier) @type
4338

39+
; val/var definitions/declarations
4440
(val_definition
4541
pattern: (identifier) @variable)
4642

@@ -53,28 +49,47 @@
5349
(var_declaration
5450
name: (identifier) @variable)
5551

56-
; imports/exports
52+
; method definition
53+
(function_declaration
54+
name: (identifier) @function.method)
55+
56+
(function_definition
57+
name: (identifier) @function.method)
5758

59+
; imports/exports
5860
(import_declaration
59-
path: (identifier) @namespace)
60-
((stable_identifier (identifier) @namespace))
61+
path: (identifier) @module)
62+
63+
(stable_identifier
64+
(identifier) @module)
6165

6266
((import_declaration
63-
path: (identifier) @type) (#match? @type "^[A-Z]"))
64-
((stable_identifier (identifier) @type) (#match? @type "^[A-Z]"))
67+
path: (identifier) @type)
68+
(#lua-match? @type "^[A-Z]"))
69+
70+
((stable_identifier
71+
(identifier) @type)
72+
(#lua-match? @type "^[A-Z]"))
6573

6674
(export_declaration
67-
path: (identifier) @namespace)
68-
((stable_identifier (identifier) @namespace))
75+
path: (identifier) @module)
76+
77+
(stable_identifier
78+
(identifier) @module)
6979

7080
((export_declaration
71-
path: (identifier) @type) (#match? @type "^[A-Z]"))
72-
((stable_identifier (identifier) @type) (#match? @type "^[A-Z]"))
81+
path: (identifier) @type)
82+
(#lua-match? @type "^[A-Z]"))
7383

74-
((namespace_selectors (identifier) @type) (#match? @type "^[A-Z]"))
84+
((stable_identifier
85+
(identifier) @type)
86+
(#lua-match? @type "^[A-Z]"))
7587

76-
; method invocation
88+
((namespace_selectors
89+
(identifier) @type)
90+
(#lua-match? @type "^[A-Z]"))
7791

92+
; method invocation
7893
(call_expression
7994
function: (identifier) @function.call)
8095

@@ -83,11 +98,11 @@
8398

8499
(call_expression
85100
function: (field_expression
86-
field: (identifier) @method.call))
101+
field: (identifier) @function.method.call))
87102

88103
((call_expression
89-
function: (identifier) @constructor)
90-
(#match? @constructor "^[A-Z]"))
104+
function: (identifier) @constructor)
105+
(#lua-match? @constructor "^[A-Z]"))
91106

92107
(generic_function
93108
function: (identifier) @function.call)
@@ -96,67 +111,75 @@
96111
interpolator: (identifier) @function.call)
97112

98113
; function definitions
99-
100114
(function_definition
101115
name: (identifier) @function)
102116

103117
(parameter
104-
name: (identifier) @parameter)
118+
name: (identifier) @variable.parameter)
105119

106120
(binding
107-
name: (identifier) @parameter)
121+
name: (identifier) @variable.parameter)
108122

109-
; method definition
123+
(lambda_expression
124+
parameters: (identifier) @variable.parameter)
110125

111-
(function_declaration
112-
name: (identifier) @method)
126+
; expressions
127+
(field_expression
128+
field: (identifier) @variable.member)
113129

114-
(function_definition
115-
name: (identifier) @method)
130+
(field_expression
131+
value: (identifier) @type
132+
(#lua-match? @type "^[A-Z]"))
116133

117-
; expressions
134+
(infix_expression
135+
operator: (identifier) @operator)
118136

119-
(infix_expression operator: (identifier) @operator)
120-
(infix_expression operator: (operator_identifier) @operator)
121-
(infix_type operator: (operator_identifier) @operator)
122-
(infix_type operator: (operator_identifier) @operator)
137+
(infix_expression
138+
operator: (operator_identifier) @operator)
123139

124-
; literals
140+
(infix_type
141+
operator: (operator_identifier) @operator)
142+
143+
(infix_type
144+
operator: (operator_identifier) @operator)
125145

146+
; literals
126147
(boolean_literal) @boolean
148+
127149
(integer_literal) @number
128-
(floating_point_literal) @float
150+
151+
(floating_point_literal) @number.float
129152

130153
[
131-
(symbol_literal)
132154
(string)
133-
(character_literal)
134155
(interpolated_string_expression)
135156
] @string
136157

137-
(interpolation "$" @punctuation.special)
158+
(character_literal) @character
159+
160+
(symbol_literal) @string.special.symbol
161+
162+
(interpolation
163+
"$" @punctuation.special)
138164

139-
;; keywords
165+
; keywords
166+
(opaque_modifier) @keyword.modifier
140167

141-
(opaque_modifier) @type.qualifier
142168
(infix_modifier) @keyword
143-
(transparent_modifier) @type.qualifier
144-
(open_modifier) @type.qualifier
169+
170+
(transparent_modifier) @keyword.modifier
171+
172+
(open_modifier) @keyword.modifier
145173

146174
[
147175
"case"
148-
"class"
149-
"enum"
150176
"extends"
151177
"derives"
152178
"finally"
153-
;; `forSome` existential types not implemented yet
154-
;; `macro` not implemented yet
179+
; `forSome` existential types not implemented yet
180+
; `macro` not implemented yet
155181
"object"
156182
"override"
157-
"package"
158-
"trait"
159-
"type"
160183
"val"
161184
"var"
162185
"with"
@@ -168,94 +191,122 @@
168191
"with"
169192
] @keyword
170193

194+
[
195+
"enum"
196+
"class"
197+
"trait"
198+
"type"
199+
] @keyword.type
200+
171201
[
172202
"abstract"
173203
"final"
174204
"lazy"
175205
"sealed"
176206
"private"
177207
"protected"
178-
] @type.qualifier
208+
] @keyword.modifier
179209

180-
(inline_modifier) @storageclass
210+
(inline_modifier) @keyword.modifier
181211

182212
(null_literal) @constant.builtin
183213

184-
(wildcard) @parameter
214+
(wildcard) @variable.parameter
185215

186-
(annotation) @attribute
216+
(namespace_wildcard
217+
[
218+
"*"
219+
"_"
220+
] @character.special)
187221

188-
;; special keywords
222+
(annotation) @attribute
189223

224+
; special keywords
190225
"new" @keyword.operator
191226

192227
[
193228
"else"
194229
"if"
195230
"match"
196231
"then"
197-
] @conditional
232+
] @keyword.conditional
198233

199234
[
200-
"("
201-
")"
202-
"["
203-
"]"
204-
"{"
205-
"}"
206-
] @punctuation.bracket
235+
"("
236+
")"
237+
"["
238+
"]"
239+
"{"
240+
"}"
241+
] @punctuation.bracket
207242

208243
[
209-
"."
210-
","
244+
"."
245+
","
246+
":"
211247
] @punctuation.delimiter
212248

213249
[
214250
"do"
215251
"for"
216252
"while"
217253
"yield"
218-
] @repeat
254+
] @keyword.repeat
219255

220256
"def" @keyword.function
221257

222258
[
223-
"=>"
224-
"<-"
225-
"@"
259+
"=>"
260+
"?=>"
261+
"="
262+
"!"
263+
"<-"
264+
"@"
226265
] @operator
227266

228-
["import" "export"] @include
267+
[
268+
"import"
269+
"export"
270+
"package"
271+
] @keyword.import
229272

230273
[
231274
"try"
232275
"catch"
233276
"throw"
234-
] @exception
277+
] @keyword.exception
235278

236279
"return" @keyword.return
237280

238-
(comment) @spell @comment
239-
(block_comment) @spell @comment
281+
[
282+
(comment)
283+
(block_comment)
284+
] @comment @spell
285+
286+
((block_comment) @comment.documentation
287+
(#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$"))
240288

241-
;; `case` is a conditional keyword in case_block
289+
; `case` is a conditional keyword in case_block
290+
(case_block
291+
(case_clause
292+
"case" @keyword.conditional))
242293

243294
(case_block
244-
(case_clause ("case") @conditional))
245-
(indented_cases
246-
(case_clause ("case") @conditional))
295+
(case_clause
296+
"=>" @punctuation.delimiter))
247297

248298
(operator_identifier) @operator
249299

250-
((identifier) @type (#match? @type "^[A-Z]"))
300+
((identifier) @type
301+
(#lua-match? @type "^[A-Z]"))
302+
251303
((identifier) @variable.builtin
252-
(#match? @variable.builtin "^this$"))
304+
(#lua-match? @variable.builtin "^this$"))
305+
306+
((identifier) @function.builtin
307+
(#lua-match? @function.builtin "^super$"))
253308

254-
(
255-
(identifier) @function.builtin
256-
(#match? @function.builtin "^super$")
257-
)
309+
; Scala CLI using directives
310+
(using_directive_key) @variable.parameter
258311

259-
;; Scala CLI using directives
260-
(using_directive_key) @parameter
261312
(using_directive_value) @string

queries/injections.scm

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
((comment) @injection.content
2+
(#set! injection.language "comment"))
3+
4+
((block_comment) @injection.content
5+
(#set! injection.language "comment"))

0 commit comments

Comments
 (0)