Debian Codegraph @

runtime/queries/julia/highlights.scm

raw symbols SCIP
1 ; ------------
2 ; Variables identifiers
3 ; ------------
4
5 (identifier) @variable
6
7 ; Remaining identifiers that start with capital letters should be types (PascalCase)
8 (
9 (identifier) @type
10 (#match? @type "^[A-Z]"))
11
12 ; SCREAMING_SNAKE_CASE
13 (
14 (identifier) @constant
15 (#match? @constant "^[A-Z][A-Z0-9_]*$"))
16
17 (const_statement
18 (assignment
19 . (identifier) @constant))
20
21 ; Field expressions are either module content or struct fields.
22 ; Module types and constants should already be captured, so this
23 ; assumes the remaining identifiers to be struct fields.
24 (field_expression
25 (_)
26 (identifier) @variable.other.member)
27
28 (quote_expression
29 ":" @string.special.symbol
30 [
31 (identifier)
32 (operator)
33 ] @string.special.symbol)
34
35 ; ------
36 ; Macros
37 ; ------
38
39 (macro_definition
40 (signature (call_expression . (identifier) @function.macro)))
41
42 (macro_identifier
43 "@" @function.macro
44 (identifier) @function.macro)
45
46 ; -------------------
47 ; Modules and Imports
48 ; -------------------
49
50 (module_definition
51 name: (identifier) @namespace)
52
53 (import_statement
54 (identifier) @namespace)
55
56 (selected_import
57 . (identifier) @namespace)
58
59 (import_path
60 (identifier) @namespace)
61
62 ; -------------------
63 ; Function definition
64 ; -------------------
65
66 ; The name now lives in the signature's call_expression (optionally wrapped in a
67 ; where_expression); short-form `f(x) = …` is an assignment with a call LHS.
68 (
69 (function_definition
70 (signature
71 [
72 (call_expression . (identifier) @function)
73 (where_expression (call_expression . (identifier) @function))
74 ]))
75 (#match? @function "^[^A-Z]"))
76
77 (
78 (assignment
79 . (call_expression . (identifier) @function))
80 (#match? @function "^[^A-Z]"))
81
82 ; ---------------
83 ; Functions calls
84 ; ---------------
85
86 (
87 (call_expression
88 (identifier) @function)
89 ; prevent constructors (PascalCase) to be highlighted as functions
90 (#match? @function "^[^A-Z]"))
91
92 (
93 (call_expression
94 (field_expression (identifier) @function .))
95 (#match? @function "^[^A-Z]"))
96
97 (
98 (broadcast_call_expression
99 (identifier) @function)
100 (#match? @function "^[^A-Z]"))
101
102 (
103 (broadcast_call_expression
104 (field_expression (identifier) @function .))
105 (#match? @function "^[^A-Z]"))
106
107
108 ; -------------------
109 ; Functions builtins
110 ; -------------------
111
112 ((identifier) @function.builtin
113 (#any-of? @function.builtin
114 "_abstracttype" "_apply_iterate" "_apply_pure" "_call_in_world" "_call_in_world_total"
115 "_call_latest" "_equiv_typedef" "_expr" "_primitivetype" "_setsuper!" "_structtype" "_typebody!"
116 "_typevar" "applicable" "apply_type" "arrayref" "arrayset" "arraysize" "const_arrayref"
117 "donotdelete" "fieldtype" "get_binding_type" "getfield" "ifelse" "invoke" "isa" "isdefined"
118 "modifyfield!" "nfields" "replacefield!" "set_binding_type!" "setfield!" "sizeof" "svec"
119 "swapfield!" "throw" "tuple" "typeassert" "typeof"))
120
121 ; -----------
122 ; Parameters
123 ; -----------
124 ; Parameters now live in the signature's argument_list: plain identifiers,
125 ; optional (assignment), splat (splat_expression) and typed (typed_expression).
126
127 (argument_list
128 (identifier) @variable.parameter)
129
130 (argument_list
131 (assignment . (identifier) @variable.parameter))
132
133 (argument_list
134 (splat_expression (identifier) @variable.parameter))
135
136 (argument_list
137 (typed_expression . (identifier) @variable.parameter))
138
139 (arrow_function_expression
140 . (identifier) @variable.parameter) ; Single parameter arrow functions
141
142 ; -----
143 ; Types
144 ; -----
145
146 ; Definitions — the type name(s) and supertype live in a type_head.
147 (type_head (_) @type)
148
149 ; Struct fields (in the body block).
150 (struct_definition
151 (block (identifier) @variable.other.member))
152
153 (struct_definition
154 (block
155 (typed_expression
156 . (identifier) @variable.other.member)))
157
158 ; Annotations
159 (parametrized_type_expression
160 (_) @type
161 (curly_expression
162 (_) @type))
163
164 (typed_expression
165 (identifier) @type . )
166
167 (where_expression
168 (identifier) @type)
169
170 (where_expression
171 (curly_expression
172 (_) @type))
173
174 ; ---------
175 ; Builtins
176 ; ---------
177
178 ; This list was generated with:
179 ;
180 ; istype(x) = typeof(x) === DataType || typeof(x) === UnionAll
181 ; get_types(m) = filter(x -> istype(Base.eval(m, x)), names(m))
182 ; type_names = sort(union(get_types(Core), get_types(Base)))
183 ;
184 ((identifier) @type.builtin
185 (#any-of? @type.builtin
186 "AbstractArray" "AbstractChannel" "AbstractChar" "AbstractDict" "AbstractDisplay"
187 "AbstractFloat" "AbstractIrrational" "AbstractLock" "AbstractMatch" "AbstractMatrix"
188 "AbstractPattern" "AbstractRange" "AbstractSet" "AbstractSlices" "AbstractString"
189 "AbstractUnitRange" "AbstractVecOrMat" "AbstractVector" "Any" "ArgumentError" "Array"
190 "AssertionError" "Atomic" "BigFloat" "BigInt" "BitArray" "BitMatrix" "BitSet" "BitVector" "Bool"
191 "BoundsError" "By" "CanonicalIndexError" "CapturedException" "CartesianIndex" "CartesianIndices"
192 "Cchar" "Cdouble" "Cfloat" "Channel" "Char" "Cint" "Cintmax_t" "Clong" "Clonglong" "Cmd" "Colon"
193 "ColumnSlices" "Complex" "ComplexF16" "ComplexF32" "ComplexF64" "ComposedFunction"
194 "CompositeException" "ConcurrencyViolationError" "Condition" "Cptrdiff_t" "Cshort" "Csize_t"
195 "Cssize_t" "Cstring" "Cuchar" "Cuint" "Cuintmax_t" "Culong" "Culonglong" "Cushort" "Cvoid"
196 "Cwchar_t" "Cwstring" "DataType" "DenseArray" "DenseMatrix" "DenseVecOrMat" "DenseVector" "Dict"
197 "DimensionMismatch" "Dims" "DivideError" "DomainError" "EOFError" "Enum" "ErrorException"
198 "Exception" "ExponentialBackOff" "Expr" "Float16" "Float32" "Float64" "Function" "GlobalRef"
199 "HTML" "IO" "IOBuffer" "IOContext" "IOStream" "IdDict" "IndexCartesian" "IndexLinear"
200 "IndexStyle" "InexactError" "InitError" "Int" "Int128" "Int16" "Int32" "Int64" "Int8" "Integer"
201 "InterruptException" "InvalidStateException" "Irrational" "KeyError" "LazyString" "LinRange"
202 "LineNumberNode" "LinearIndices" "LoadError" "Lt" "MIME" "Matrix" "Method" "MethodError"
203 "Missing" "MissingException" "Module" "NTuple" "NamedTuple" "Nothing" "Number" "Ordering"
204 "OrdinalRange" "OutOfMemoryError" "OverflowError" "Pair" "ParseError" "PartialQuickSort" "Perm"
205 "PermutedDimsArray" "Pipe" "ProcessFailedException" "Ptr" "QuoteNode" "Rational" "RawFD"
206 "ReadOnlyMemoryError" "Real" "ReentrantLock" "Ref" "Regex" "RegexMatch" "Returns"
207 "ReverseOrdering" "RoundingMode" "RowSlices" "SegmentationFault" "Set" "Signed" "Slices" "Some"
208 "SpinLock" "StackFrame" "StackOverflowError" "StackTrace" "Stateful" "StepRange" "StepRangeLen"
209 "StridedArray" "StridedMatrix" "StridedVecOrMat" "StridedVector" "String" "StringIndexError"
210 "SubArray" "SubString" "SubstitutionString" "Symbol" "SystemError" "Task" "TaskFailedException"
211 "Text" "TextDisplay" "Timer" "Tmstruct" "Tuple" "Type" "TypeError" "TypeVar" "UInt" "UInt128"
212 "UInt16" "UInt32" "UInt64" "UInt8" "UndefInitializer" "UndefKeywordError" "UndefRefError"
213 "UndefVarError" "Union" "UnionAll" "UnitRange" "Unsigned" "Val" "VecElement" "VecOrMat" "Vector"
214 "VersionNumber" "WeakKeyDict" "WeakRef"))
215
216 ((identifier) @variable.builtin
217 (#any-of? @variable.builtin "begin" "end"))
218
219 ((identifier) @variable.builtin
220 (#any-of? @variable.builtin "begin" "end"))
221
222
223 ; --------
224 ; Keywords
225 ; --------
226
227 [
228 "global"
229 "local"
230 ] @keyword
231
232 (compound_statement
233 [
234 "begin"
235 "end"
236 ] @keyword)
237
238 (quote_statement
239 [
240 "quote"
241 "end"
242 ] @keyword)
243
244 (let_statement
245 [
246 "let"
247 "end"
248 ] @keyword)
249
250 (if_statement
251 [
252 "if"
253 "end"
254 ] @keyword.control.conditional)
255
256 (elseif_clause
257 "elseif" @keyword.control.conditional)
258
259 (else_clause
260 "else" @keyword.control.conditional)
261
262 (if_clause
263 "if" @keyword.control.conditional) ; `if` clause in comprehensions
264
265 (ternary_expression
266 [
267 "?"
268 ":"
269 ] @keyword.control.conditional)
270
271 (try_statement
272 [
273 "try"
274 "end"
275 ] @keyword.control.exception)
276
277 (finally_clause
278 "finally" @keyword.control.exception)
279
280 (catch_clause
281 "catch" @keyword.control.exception)
282
283 (for_statement
284 [
285 "for"
286 "end"
287 ] @keyword.control.repeat)
288
289 (while_statement
290 [
291 "while"
292 "end"
293 ] @keyword.control.repeat)
294
295 (for_clause
296 "for" @keyword.control.repeat)
297
298 [
299 (break_statement)
300 (continue_statement)
301 ] @keyword.control.repeat
302
303 (module_definition
304 [
305 "module"
306 "baremodule"
307 "end"
308 ] @keyword.control.import)
309
310 (import_statement
311 [
312 "import"
313 "using"
314 ] @keyword.control.import)
315
316 (import_alias
317 "as" @keyword.control.import)
318
319 (export_statement
320 "export" @keyword.control.import)
321
322 (selected_import
323 ":" @punctuation.delimiter)
324
325 (struct_definition
326 [
327 "struct"
328 "end"
329 ] @keyword)
330
331 (macro_definition
332 [
333 "macro"
334 "end"
335 ] @keyword)
336
337 (function_definition
338 [
339 "function"
340 "end"
341 ] @keyword.function)
342
343 (do_clause
344 [
345 "do"
346 "end"
347 ] @keyword.function)
348
349 (return_statement
350 "return" @keyword.control.return)
351
352 [
353 "const"
354 "mutable"
355 ] @keyword.storage.modifier
356
357 ; ---------
358 ; Operators
359 ; ---------
360
361 ; `=` and `∈` are now `(operator)` nodes rather than standalone tokens.
362 (operator) @operator
363
364 (adjoint_expression
365 "'" @operator)
366
367 (range_expression
368 ":" @operator)
369
370 ((operator) @keyword.operator
371 (#any-of? @keyword.operator "in" "isa"))
372
373 (where_expression
374 "where" @keyword.operator)
375
376 (binary_expression
377 (_)
378 (operator) @operator
379 (identifier) @function
380 (#any-of? @operator "|>" ".|>"))
381
382 ; ------------
383 ; Punctuations
384 ; ------------
385
386 [
387 "."
388 ","
389 ";"
390 "::"
391 "->"
392 ] @punctuation.delimiter
393
394 "..." @punctuation.special
395
396 [
397 "("
398 ")"
399 "["
400 "]"
401 "{"
402 "}"
403 ] @punctuation.bracket
404
405 ; ---------
406 ; Literals
407 ; ---------
408
409 (boolean_literal) @constant.builtin.boolean
410
411 (integer_literal) @constant.numeric.integer
412
413 (float_literal) @constant.numeric.float
414
415 (
416 ((identifier) @constant.numeric.float)
417 (#match? @constant.numeric.float "^((Inf|NaN)(16|32|64)?)$"))
418
419 (
420 ((identifier) @constant.builtin)
421 (#match? @constant.builtin "^(nothing|missing|undef)$"))
422
423 (character_literal) @constant.character
424
425 (escape_sequence) @constant.character.escape
426
427 (string_literal) @string
428
429 (prefixed_string_literal
430 prefix: (identifier) @function.macro) @string
431
432 (command_literal) @string
433
434 (prefixed_command_literal
435 prefix: (identifier) @function.macro) @string
436
437 ; ---------
438 ; Comments
439 ; ---------
440
441 [
442 (line_comment)
443 (block_comment)
444 ] @comment