Gleam-authored Zed extension (Gleam → Wasm guest) for Gleam LSP + highlighting
2.6 kB
131 lines
1; Comments
2(module_comment) @comment
3(statement_comment) @comment
4(comment) @comment
5
6; Constants
7(constant
8 name: (identifier) @constant)
9
10; Variables
11(identifier) @variable
12(discard) @comment.unused
13
14; Modules
15(module) @module
16(import alias: (identifier) @module)
17(remote_type_identifier
18 module: (identifier) @module)
19(remote_constructor_name
20 module: (identifier) @module)
21((field_access
22 record: (identifier) @module
23 field: (label) @function)
24 (#is-not? local))
25
26; Functions
27(unqualified_import (identifier) @function)
28(unqualified_import "type" (type_identifier) @type)
29(unqualified_import (type_identifier) @constructor)
30(function
31 name: (identifier) @function.definition)
32(external_function
33 name: (identifier) @function.definition)
34(function_parameter
35 name: (identifier) @variable.parameter)
36((function_call
37 function: (identifier) @function.call)
38 (#is-not? local))
39((binary_expression
40 operator: "|>"
41 right: (identifier) @function.call)
42 (#is-not? local))
43
44; "Properties"
45; Assumed to be intended to refer to a name for a field; something that comes
46; before ":" or after "."
47; e.g. record field names, tuple indices, names for named arguments, etc
48(label) @property
49(tuple_access
50 index: (integer) @property)
51
52; Attributes
53(attribute
54 "@" @attribute
55 name: (identifier) @attribute)
56
57(attribute_value (identifier) @constant)
58
59; Type names
60(remote_type_identifier) @type
61(type_identifier) @type
62
63; Data constructors
64(constructor_name) @constructor
65
66; Literals
67(string) @string
68((escape_sequence) @warning
69 ; Deprecated in v0.33.0-rc2:
70 (#eq? @warning "\\e"))
71(escape_sequence) @string.escape
72(bit_array_segment_option) @function.builtin
73(integer) @number
74(float) @number
75
76; Reserved identifiers
77; TODO: when tree-sitter supports `#any-of?` in the Rust bindings,
78; refactor this to use `#any-of?` rather than `#match?`
79((identifier) @warning
80 (#match? @warning "^(auto|delegate|derive|else|implement|macro|test)$"))
81
82; Keywords
83[
84 (visibility_modifier) ; "pub"
85 (opacity_modifier) ; "opaque"
86 "as"
87 "assert"
88 "case"
89 "const"
90 "echo"
91 ; DEPRECATED: 'external' was removed in v0.30.
92 "external"
93 "fn"
94 "if"
95 "import"
96 "let"
97 "panic"
98 "todo"
99 "type"
100 "use"
101] @keyword
102
103; Operators
104(binary_expression
105 operator: _ @operator)
106(boolean_negation "!" @operator)
107(integer_negation "-" @operator)
108
109; Punctuation
110[
111 "("
112 ")"
113 "["
114 "]"
115 "{"
116 "}"
117 "<<"
118 ">>"
119] @punctuation.bracket
120[
121 "."
122 ","
123 ;; Controversial -- maybe some are operators?
124 ":"
125 "#"
126 "="
127 "->"
128 ".."
129 "-"
130 "<-"
131] @punctuation.delimiter