Debian Codegraph @

runtime/queries/gleam/highlights.scm

raw symbols SCIP
1 ; Variables
2 (identifier) @variable
3 (discard) @comment.unused ; `_` pattern
4 (hole) @comment.unused ; `_`, `_foo` unused variable
5
6 ; Comments
7 (module_comment) @comment.line.documentation
8 (statement_comment) @comment.line.documentation
9 (comment) @comment.line
10
11 ; Constants
12 (constant
13 name: (identifier) @constant)
14
15 ; Modules
16 (module) @namespace
17 (import alias: (identifier) @namespace)
18 (remote_type_identifier
19 module: (identifier) @namespace)
20 (remote_constructor_name
21 module: (identifier) @namespace)
22 ((field_access
23 record: (identifier) @namespace
24 field: (label) @function)
25 (#is-not? local))
26
27 ; =========
28 ; Functions
29 ; =========
30
31 (unqualified_import (identifier) @function)
32 (unqualified_import "type" (type_identifier) @type)
33 (unqualified_import (type_identifier) @constructor)
34 (function
35 name: (identifier) @function)
36 (external_function
37 name: (identifier) @function)
38 (function_parameter
39 name: (identifier) @variable.parameter)
40 ((function_call
41 function: (identifier) @function)
42 (#is-not? local))
43 ; highlights `a` in `|> a` as function
44 ((binary_expression
45 operator: "|>"
46 right: (identifier) @function)
47 (#is-not? local))
48
49 ; =========
50 ; Misc
51 ; =========
52
53 ; "Properties"
54 ; Assumed to be intended to refer to a name for a field; something that comes
55 ; before ":" or after "."
56 ; e.g. record field names, tuple indices, names for named arguments, etc
57 (label) @variable.other.member
58 (tuple_access
59 index: (integer) @variable.other.member)
60
61 ; Attributes
62 (attribute
63 "@" @attribute
64 name: (identifier) @attribute)
65
66 (attribute_value (identifier) @constant)
67
68 ; =========
69 ; Types
70 ; =========
71
72 (type_hole) @comment.unused
73
74 ; Type names
75 (remote_type_identifier) @type
76 (type_identifier) @type
77
78 ; Generic types
79 [
80 ; in `pub type Dict(key, value)` this is `key` and `value`
81 (type_parameter)
82 ; in `pub fn size(dict: Dict(key, value)) -> Int` this is `key` and `value`
83 (type_var)
84 ] @type
85
86 ; Data constructors
87 (constructor_name) @constructor
88
89 ; built-ins
90 ((constructor_name) @constant.builtin
91 (#any-of? @constant.builtin "False" "True"))
92 ((constructor_name) @constant.builtin
93 (#any-of? @constant.builtin "Nil"))
94 ((constructor_name) @type.enum.variant.builtin
95 (#any-of? @type.enum.variant.builtin "Ok" "Error" "Some" "None"))
96
97 ; =========
98 ; Literals
99 ; =========
100
101 (string) @string
102 (escape_sequence) @constant.character.escape
103 ((escape_sequence) @warning
104 (#eq? @warning "\\e")) ; deprecated escape sequence
105 (bit_array_segment_option) @function.builtin
106 (integer) @constant.numeric.integer
107 (float) @constant.numeric.float
108
109 ; Reserved identifiers
110 ((identifier) @error
111 (#any-of? @error "auto" "delegate" "derive" "else" "implement" "macro" "test"))
112
113 ; =========
114 ; Keywords
115 ; =========
116
117 [
118 (visibility_modifier) ; "pub"
119 (opacity_modifier) ; "opaque"
120 "as"
121 "assert"
122 "case"
123 "const"
124 ; DEPRECATED: 'external' was removed in v0.30.
125 "external"
126 "fn"
127 "if"
128 "import"
129 "let"
130 "panic"
131 "todo"
132 "type"
133 "use"
134 "echo"
135 ] @keyword
136
137 ; =========
138 ; Operators
139 ; =========
140
141 (binary_expression
142 operator: _ @operator)
143 (boolean_negation "!" @operator)
144 (integer_negation "-" @operator)
145
146 [
147 "->"
148 "-"
149 "="
150 ".."
151 "<-"
152 ; OR clause in patterns
153 "|"
154 ] @operator
155
156 ; ==========
157 ; Punctuation
158 ; ==========
159
160 [
161 "("
162 ")"
163 "["
164 "]"
165 "{"
166 "}"
167 "<<"
168 ">>"
169 ] @punctuation.bracket
170
171 (tuple_type "#" @punctuation.bracket)
172 (tuple "#" @punctuation.bracket)
173 (tuple_pattern "#" @punctuation.bracket)
174
175 [
176 ","
177 ":"
178 ] @punctuation.delimiter
179
180 ; the `/` in `import gleam/list`
181 (import (module "/" @punctuation.delimiter))
182
183 [
184 "."
185 ] @punctuation
186
187 ; affects e.g. `replace` in `string.replace("+", "-")`
188 ; without this, it would be highlighted as a field instead of function
189 (function_call (field_access (label) @function))
190
191 ; highlights `floor` in `|> float.floor` as function
192 (binary_expression
193 left: (_) "|>"
194 right: (field_access
195 record: (identifier) "."
196 field: (label) @function))