Debian Codegraph @

runtime/queries/erlang/highlights.scm

raw symbols SCIP
1 ; Comments
2 (tripledot) @comment.unused
3
4 [(comment) (line_comment) (shebang)] @comment
5
6 ; Basic types
7 (variable) @variable
8 (atom) @string.special.symbol
9 ((atom) @constant.builtin.boolean
10 (#any-of? @constant.builtin.boolean "true" "false"))
11 [(string) (sigil)] @string
12 (character) @constant.character
13 (escape_sequence) @constant.character.escape
14
15 (integer) @constant.numeric.integer
16 (float) @constant.numeric.float
17
18 ; Punctuation
19 ["," "." "-" ";"] @punctuation.delimiter
20 ["(" ")" "#" "{" "}" "[" "]" "<<" ">>"] @punctuation.bracket
21
22 ; Operators
23 (binary_operator operator: _ @operator)
24 (unary_operator operator: _ @operator)
25 ["/" ":" "->"] @operator
26
27 (binary_operator
28 left: (atom) @function
29 operator: "/"
30 right: (integer) @constant.numeric.integer)
31
32 ((binary_operator operator: _ @keyword.operator)
33 (#match? @keyword.operator "^\\w+$"))
34 ((unary_operator operator: _ @keyword.operator)
35 (#match? @keyword.operator "^\\w+$"))
36
37 ; Functions
38 (function_clause name: (atom) @function)
39 (call module: (atom) @namespace)
40 (call function: (atom) @function)
41 (stab_clause name: (atom) @function)
42 (function_capture module: (atom) @namespace)
43 (function_capture function: (atom) @function)
44
45 ; Keywords
46 (attribute name: (atom) @keyword)
47
48 ["case" "fun" "if" "of" "when" "end" "receive" "try" "catch" "after" "begin" "maybe"] @keyword
49
50 ; Attributes
51 ; module declaration
52 (attribute
53 name: (atom) @keyword
54 (arguments (atom) @namespace)
55 (#any-of? @keyword "module" "behaviour" "behavior"))
56
57 (attribute
58 name: (atom) @keyword
59 (arguments
60 .
61 (atom) @namespace)
62 (#eq? @keyword "import"))
63
64 (attribute
65 name: (atom) @keyword
66 (arguments
67 .
68 [(atom) @type (macro)]
69 [
70 (tuple (atom)? @variable.other.member)
71 (tuple
72 (binary_operator
73 left: (atom) @variable.other.member
74 operator: ["=" "::"]))
75 (tuple
76 (binary_operator
77 left:
78 (binary_operator
79 left: (atom) @variable.other.member
80 operator: "=")
81 operator: "::"))
82 ])
83 (#eq? @keyword "record"))
84
85 (attribute
86 name: (atom) @keyword
87 (arguments
88 .
89 [
90 (atom) @constant
91 (variable) @constant
92 (call
93 function:
94 [(variable) (atom)] @keyword.directive)
95 ])
96 (#eq? @keyword "define"))
97
98 (attribute
99 name: (atom) @keyword
100 (arguments
101 (_) @keyword.directive)
102 (#any-of? @keyword "ifndef" "ifdef"))
103
104 (attribute
105 name: (atom) @keyword
106 module: (atom) @namespace
107 (#any-of? @keyword "spec" "callback"))
108
109 (attribute
110 name: (atom) @keyword
111 (arguments [
112 (string)
113 (sigil)
114 ] @comment.block.documentation)
115 (#any-of? @keyword "doc" "moduledoc"))
116
117 ; Parameters
118 ; specs
119 ((attribute
120 name: (atom) @keyword
121 (stab_clause
122 pattern: (arguments (variable)? @variable.parameter)
123 body: (variable)? @variable.parameter))
124 (#any-of? @keyword "spec" "callback"))
125 ; functions
126 (function_clause pattern: (arguments (variable) @variable.parameter))
127 ; anonymous functions
128 (stab_clause pattern: (arguments (variable) @variable.parameter))
129 ; parametric types
130 ((attribute
131 name: (atom) @keyword
132 (arguments
133 (binary_operator
134 left: (call (arguments (variable) @variable.parameter))
135 operator: "::")))
136 (#any-of? @keyword "type" "opaque" "nominal"))
137 ; macros
138 ((attribute
139 name: (atom) @keyword
140 (arguments
141 (call (arguments (variable) @variable.parameter))))
142 (#eq? @keyword "define"))
143
144 ; Records
145 (record_content
146 (binary_operator
147 left: (atom) @variable.other.member
148 operator: "="))
149
150 (record field: (atom) @variable.other.member)
151 (record name: (atom) @type)
152
153 ; Ignored variables
154 ((variable) @comment.unused
155 (#match? @comment.unused "^_"))
156
157 ; Macros
158 (macro
159 "?"+ @keyword.directive
160 name: (_) @keyword.directive)
161
162 (macro
163 "?"+ @constant
164 name: (_) @constant
165 !arguments)