···
+
lower_ident: '[[:lower:]][[:word:]]*'
+
upper_ident: '[[:upper:]][[:word:]]*'
+
- include: constant_def
+
- include: function_def
+
- include: function_call
+
# Attributes (annotations)
+
- match: ^\s*(@{{lower_ident}})\(
+
1: variable.other.constant.gleam
+
- meta_scope: meta.annotation.gleam
+
- match: ^\s*(@{{lower_ident}})
+
scope: meta.annotation.gleam
+
1: variable.other.constant.gleam
+
# Arguments (to a function call, record constructor, or attribute)
+
- include: function_def
+
- include: function_call
+
- match: '\b{{lower_ident}}:'
+
scope: constant.other.gleam
+
scope: punctuation.definition.generic.begin.gleam
+
- match: \b(bytes|int|float|bits|utf8|utf16|utf32|utf8_codepoint|utf16_codepoint|utf32_codepoint|signed|unsigned|big|little|native|unit|size)\b
+
scope: keyword.other.gleam
+
scope: punctuation.definition.generic.end.gleam
+
scope: punctuation.section.block.begin.gleam
+
scope: punctuation.section.block.end.gleam
+
scope: punctuation.definition.comment.line.gleam
+
- meta_scope: comment.line.gleam
+
- match: \b(const)\s+({{lower_ident}})\b
+
2: entity.name.constant.gleam
+
- match: \b(?:{{lower_ident}}\.)*({{lower_ident}})\(
+
1: variable.function.gleam
+
- match: \b(fn)(?:[[:space:]]+({{lower_ident}}))?[[:space:]]*\(
+
1: storage.type.function.gleam
+
2: entity.name.function.gleam
+
push: function_def_args
+
- include: function_def
+
scope: keyword.operator.gleam
+
- match: \b(?:({{lower_ident}})[[:space:]]+)?({{lower_ident}}:)
+
1: constant.other.gleam
+
2: variable.parameter.gleam
+
push: function_def_args
+
scope: keyword.control.import.gleam
+
scope: keyword.control.import.gleam
+
- match: \b(?:{{lower_ident}}/)*{{lower_ident}}\b
+
scope: entity.name.namespace.gleam
+
1: punctuation.accessor.gleam
+
2: punctuation.definition.generic.begin.gleam
+
scope: keyword.control.import.gleam
+
scope: storage.type.gleam
+
scope: punctuation.definition.generic.end.gleam
+
- match: \b(as|assert|case|const|echo|if|let|panic|todo|use)\b
+
scope: keyword.other.gleam
+
- match: \b(opaque|pub)\b
+
scope: storage.modifier.gleam
+
scope: storage.type.gleam
+
scope: storage.type.function.gleam
+
# Reserved for future use
+
- match: \b(auto|delegate|derive|else|implement|macro|test)\b
+
scope: invalid.illegal.gleam
+
- match: \b0b[01][01_]*\b
+
scope: constant.numeric.binary.gleam
+
- match: \b0o[0-7][0-7_]*\b
+
scope: constant.numeric.octal.gleam
+
- match: \b[0-9][0-9_]*(\.[0-9_]*(e-?[0-9][0-9_]*)?)?\b
+
scope: constant.numeric.decimal.gleam
+
- match: \b0x[[:xdigit:]][[:xdigit:]_]*\b
+
scope: constant.numeric.hexadecimal.gleam
+
scope: keyword.operator.assignment.gleam
+
- match: (\|>|\.\.|<=\.|>=\.|==\.|!=\.|<\.|>\.|<=|>=|==|!=|<|>|<>)
+
scope: keyword.operator.gleam
+
scope: keyword.operator.assignment.gleam
+
scope: keyword.operator.gleam
+
- match: (\+\.|\-\.|/\.|\*\.|%\.|\+|\-|/|\*|%)
+
scope: keyword.operator.arithmetic.gleam
+
scope: keyword.operator.logical.gleam
+
scope: keyword.operator.gleam
+
# Punctuation (separators, accessors)
+
scope: punctuation.accessor.gleam
+
scope: punctuation.separator.gleam
+
# Records (constructors with arguments)
+
- match: \b((?:{{lower_ident}}\.)*{{upper_ident}})\(
+
1: entity.name.type.gleam
+
scope: punctuation.definition.string.begin.gleam
+
- meta_scope: string.quoted.double.gleam
+
scope: constant.character.escape.gleam
+
- match: \\u\{[[:xdigit:]]{1,6}\}
+
scope: constant.character.escape.gleam
+
scope: invalid.illegal.gleam
+
scope: punctuation.definition.string.end.gleam
+
# Types and constructors
+
- match: \b(?:{{lower_ident}}\.)*{{upper_ident}}\b
+
scope: entity.name.type.gleam
+
- match: \b_{{lower_ident}}\b
+
scope: comment.line.gleam