···
11
+
lower_ident: '[[:lower:]][[:word:]]*'
12
+
upper_ident: '[[:upper:]][[:word:]]*'
18
+
- include: attribute
19
+
- include: bitstring
22
+
- include: constant_def
23
+
- include: function_def
25
+
- include: function_call
30
+
- include: punctuation
32
+
- include: unused_name
33
+
- include: type_name
35
+
# Attributes (annotations)
37
+
- match: ^\s*(@{{lower_ident}})\(
39
+
1: variable.other.constant.gleam
41
+
- include: arguments
42
+
- meta_scope: meta.annotation.gleam
43
+
- match: ^\s*(@{{lower_ident}})
44
+
scope: meta.annotation.gleam
46
+
1: variable.other.constant.gleam
48
+
# Arguments (to a function call, record constructor, or attribute)
50
+
- include: bitstring
53
+
- include: function_def
54
+
- include: function_call
58
+
- include: punctuation
60
+
- include: unused_name
61
+
- include: type_name
62
+
- match: '\b{{lower_ident}}:'
63
+
scope: constant.other.gleam
70
+
scope: punctuation.definition.generic.begin.gleam
74
+
- match: \b(bytes|int|float|bits|utf8|utf16|utf32|utf8_codepoint|utf16_codepoint|utf32_codepoint|signed|unsigned|big|little|native|unit|size)\b
75
+
scope: keyword.other.gleam
77
+
scope: punctuation.definition.generic.end.gleam
83
+
scope: punctuation.section.block.begin.gleam
86
+
scope: punctuation.section.block.end.gleam
92
+
scope: punctuation.definition.comment.line.gleam
94
+
- meta_scope: comment.line.gleam
98
+
# Constant definitions
100
+
- match: \b(const)\s+({{lower_ident}})\b
102
+
1: keyword.other.gleam
103
+
2: entity.name.constant.gleam
107
+
- match: \b(?:{{lower_ident}}\.)*({{lower_ident}})\(
109
+
1: variable.function.gleam
112
+
# Function definitions
114
+
- match: \b(fn)(?:[[:space:]]+({{lower_ident}}))?[[:space:]]*\(
116
+
1: storage.type.function.gleam
117
+
2: entity.name.function.gleam
118
+
push: function_def_args
120
+
# Function arguments
122
+
- include: function_def
123
+
- include: punctuation
124
+
- include: type_name
125
+
- include: unused_name
127
+
scope: keyword.operator.gleam
128
+
- match: \b(?:({{lower_ident}})[[:space:]]+)?({{lower_ident}}:)
130
+
1: constant.other.gleam
131
+
2: variable.parameter.gleam
133
+
push: function_def_args
140
+
scope: keyword.control.import.gleam
143
+
scope: keyword.control.import.gleam
144
+
- match: \b(?:{{lower_ident}}/)*{{lower_ident}}\b
145
+
scope: entity.name.namespace.gleam
148
+
1: punctuation.accessor.gleam
149
+
2: punctuation.definition.generic.begin.gleam
151
+
- include: punctuation
152
+
- include: type_name
154
+
scope: keyword.control.import.gleam
156
+
scope: storage.type.gleam
158
+
scope: punctuation.definition.generic.end.gleam
165
+
- match: \b(as|assert|case|const|echo|if|let|panic|todo|use)\b
166
+
scope: keyword.other.gleam
167
+
- match: \b(opaque|pub)\b
168
+
scope: storage.modifier.gleam
170
+
scope: storage.type.gleam
172
+
scope: storage.type.function.gleam
173
+
# Reserved for future use
174
+
- match: \b(auto|delegate|derive|else|implement|macro|test)\b
175
+
scope: invalid.illegal.gleam
179
+
- match: \b0b[01][01_]*\b
180
+
scope: constant.numeric.binary.gleam
181
+
- match: \b0o[0-7][0-7_]*\b
182
+
scope: constant.numeric.octal.gleam
183
+
- match: \b[0-9][0-9_]*(\.[0-9_]*(e-?[0-9][0-9_]*)?)?\b
184
+
scope: constant.numeric.decimal.gleam
185
+
- match: \b0x[[:xdigit:]][[:xdigit:]_]*\b
186
+
scope: constant.numeric.hexadecimal.gleam
191
+
scope: keyword.operator.assignment.gleam
192
+
- match: (\|>|\.\.|<=\.|>=\.|==\.|!=\.|<\.|>\.|<=|>=|==|!=|<|>|<>)
193
+
scope: keyword.operator.gleam
195
+
scope: keyword.operator.assignment.gleam
197
+
scope: keyword.operator.gleam
198
+
- match: (\+\.|\-\.|/\.|\*\.|%\.|\+|\-|/|\*|%)
199
+
scope: keyword.operator.arithmetic.gleam
201
+
scope: keyword.operator.logical.gleam
203
+
scope: keyword.operator.gleam
205
+
# Punctuation (separators, accessors)
208
+
scope: punctuation.accessor.gleam
210
+
scope: punctuation.separator.gleam
212
+
# Records (constructors with arguments)
214
+
- match: \b((?:{{lower_ident}}\.)*{{upper_ident}})\(
216
+
1: entity.name.type.gleam
222
+
scope: punctuation.definition.string.begin.gleam
224
+
- meta_scope: string.quoted.double.gleam
225
+
- match: \\[fnrt"\\]
226
+
scope: constant.character.escape.gleam
227
+
- match: \\u\{[[:xdigit:]]{1,6}\}
228
+
scope: constant.character.escape.gleam
230
+
scope: invalid.illegal.gleam
232
+
scope: punctuation.definition.string.end.gleam
235
+
# Types and constructors
237
+
- match: \b(?:{{lower_ident}}\.)*{{upper_ident}}\b
238
+
scope: entity.name.type.gleam
242
+
- match: \b_{{lower_ident}}\b
243
+
scope: comment.line.gleam