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)
32(external_function
33 name: (identifier) @function)
34(function_parameter
35 name: (identifier) @variable.parameter)
36((function_call
37 function: (identifier) @function)
38 (#is-not? local))
39((binary_expression
40 operator: "|>"
41 right: (identifier) @function)
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_string_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|echo)$"))
81
82; Keywords
83[
84 (visibility_modifier) ; "pub"
85 (opacity_modifier) ; "opaque"
86 "as"
87 "assert"
88 "case"
89 "const"
90 ; DEPRECATED: 'external' was removed in v0.30.
91 "external"
92 "fn"
93 "if"
94 "import"
95 "let"
96 "panic"
97 "todo"
98 "type"
99 "use"
100] @keyword
101
102; Operators
103(binary_expression
104 operator: _ @operator)
105(boolean_negation "!" @operator)
106(integer_negation "-" @operator)
107
108; Punctuation
109[
110 "("
111 ")"
112 "["
113 "]"
114 "{"
115 "}"
116 "<<"
117 ">>"
118] @punctuation.bracket
119[
120 "."
121 ","
122 ;; Controversial -- maybe some are operators?
123 ":"
124 "#"
125 "="
126 "->"
127 ".."
128 "-"
129 "<-"
130] @punctuation.delimiter