highlights.scm

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