Debian Codegraph @

runtime/queries/scala/highlights.scm

raw symbols SCIP
1 ; CREDITS @stumash ([email protected])
2
3 ;; variables
4
5 (identifier) @variable
6
7 (operator_identifier) @operator
8
9 ((identifier) @variable.builtin
10 (#match? @variable.builtin "^this$"))
11
12 (interpolation) @none
13
14 ; Assume other uppercase names constants.
15 ; NOTE: In order to distinguish constants we highlight
16 ; all the identifiers that are uppercased. But this solution
17 ; is not suitable for all occurrences e.g. it will highlight
18 ; an uppercased method as a constant if used with no params.
19 ; Introducing highlighting for those specific cases, is probably
20 ; best way to resolve the issue.
21 ((identifier) @constant (#match? @constant "^[A-Z]"))
22
23 ;; types
24
25 (type_identifier) @type
26
27 (class_definition
28 name: (identifier) @type)
29
30 (object_definition
31 name: (identifier) @type)
32
33 (trait_definition
34 name: (identifier) @type)
35
36 (type_definition
37 name: (type_identifier) @type)
38
39 (full_enum_case
40 name: (identifier) @type)
41
42 (simple_enum_case
43 name: (identifier) @type)
44
45 ;; val/var definitions/declarations
46
47 (val_definition
48 pattern: (identifier) @variable)
49
50 (var_definition
51 pattern: (identifier) @variable)
52
53 (val_declaration
54 name: (identifier) @variable)
55
56 (var_declaration
57 name: (identifier) @variable)
58
59 ; function definitions/declarations
60
61 (function_declaration
62 name: (identifier) @function.method)
63
64 (function_definition
65 name: (identifier) @function.method)
66
67 ; imports/exports
68
69 (import_declaration
70 path: (identifier) @namespace)
71 ((stable_identifier (identifier) @namespace))
72
73 ((import_declaration
74 path: (identifier) @type) (#match? @type "^[A-Z]"))
75 ((stable_identifier (identifier) @type) (#match? @type "^[A-Z]"))
76
77 (export_declaration
78 path: (identifier) @namespace)
79 ((stable_identifier (identifier) @namespace))
80
81 ((export_declaration
82 path: (identifier) @type) (#match? @type "^[A-Z]"))
83 ((stable_identifier (identifier) @type) (#match? @type "^[A-Z]"))
84
85 ((namespace_selectors (identifier) @type) (#match? @type "^[A-Z]"))
86
87 ; method invocation
88
89 ; Member access
90 (field_expression field: (identifier) @variable.other.member)
91 (field_expression value: (identifier) @type
92 (#match? @type "^[A-Z]"))
93
94 (call_expression
95 function: (identifier) @function)
96
97 (call_expression
98 function: (operator_identifier) @function)
99
100 (call_expression
101 function: (field_expression
102 field: (identifier) @function.method))
103
104 (call_expression
105 function: (field_expression
106 field: (operator_identifier) @function.method))
107
108 ((call_expression
109 function: (identifier) @variable.other.member)
110 (#match? @variable.other.member "^[A-Z]"))
111
112 (generic_function
113 function: (identifier) @function)
114
115 (interpolated_string_expression
116 interpolator: (identifier) @function)
117
118 (
119 (identifier) @function.builtin
120 (#match? @function.builtin "^super$")
121 )
122
123 ; function definitions
124
125 (function_definition
126 name: (identifier) @function)
127
128 (function_definition
129 name: (operator_identifier) @function)
130
131 (parameter
132 name: (identifier) @variable.parameter)
133
134 (binding
135 name: (identifier) @variable.parameter)
136
137 ; expressions
138
139
140 (infix_expression operator: (identifier) @operator)
141 (infix_expression operator: (operator_identifier) @operator)
142 (infix_type operator: (operator_identifier) @operator)
143 (infix_type operator: (operator_identifier) @operator)
144
145 ; literals
146 (boolean_literal) @constant.builtin.boolean
147 (integer_literal) @constant.numeric.integer
148 (floating_point_literal) @constant.numeric.float
149
150 [
151 (string)
152 (character_literal)
153 (interpolated_string_expression)
154 ] @string
155
156 (interpolation "$" @punctuation.special)
157
158 ; annotations
159
160 (annotation) @attribute
161
162 ;; keywords
163
164 ;; storage in TextMate scope lingo means field or type
165 [
166 (opaque_modifier)
167 (infix_modifier)
168 (transparent_modifier)
169 (open_modifier)
170 (tracked_modifier)
171 (into_modifier)
172 "abstract"
173 "final"
174 "implicit"
175 "lazy"
176 "override"
177 "private"
178 "protected"
179 "sealed"
180 ] @keyword.storage.modifier
181
182 [
183 "class"
184 "enum"
185 "extension"
186 "given"
187 "object"
188 "package"
189 "trait"
190 "type"
191 "val"
192 "var"
193 ] @keyword.storage.type
194
195 [
196 "as"
197 "derives"
198 "end"
199 "extends"
200 ;; `forSome` existential types not implemented yet
201 ;; `macro` not implemented yet
202 ;; `throws`
203 "using"
204 "with"
205 ] @keyword
206
207 (null_literal) @constant.builtin
208 (wildcard) @keyword
209
210 ;; special keywords
211
212 "new" @keyword.operator
213
214 [
215 "case"
216 "catch"
217 "else"
218 "finally"
219 "if"
220 "match"
221 "then"
222 "throw"
223 "try"
224 ] @keyword.control.conditional
225
226 [
227 "("
228 ")"
229 "["
230 "]"
231 "{"
232 "}"
233 ] @punctuation.bracket
234
235 [
236 "."
237 ","
238 ] @punctuation.delimiter
239
240 [
241 "do"
242 "for"
243 "while"
244 "yield"
245 ] @keyword.control.repeat
246
247 "def" @keyword.function
248
249 [
250 "=>"
251 "<-"
252 "@"
253 ] @keyword.operator
254
255 "import" @keyword.control.import
256
257 "export" @keyword.control.import
258
259 "return" @keyword.control.return
260
261 [(comment) (block_comment)] @comment
262
263 ;; `case` is a conditional keyword in case_block
264
265 (case_block
266 (case_clause ("case") @keyword.control.conditional))