highlights.scm

  1; Comments
  2(module_comment) @comment
  3(statement_comment) @comment
  4(comment) @comment
  5
  6; Constants
  7(constant
  8  name: (identifier) @constant)
  9
 10; Modules
 11(module) @module
 12(import alias: (identifier) @module)
 13(remote_type_identifier
 14  module: (identifier) @module)
 15(remote_constructor_name
 16  module: (identifier) @module)
 17((field_access
 18  record: (identifier) @module
 19  field: (label) @function)
 20 (#is-not? local))
 21
 22; Functions
 23(unqualified_import (identifier) @function)
 24(unqualified_import "type" (type_identifier) @type)
 25(unqualified_import (type_identifier) @constructor)
 26(function
 27  name: (identifier) @function)
 28(external_function
 29  name: (identifier) @function)
 30(function_parameter
 31  name: (identifier) @variable.parameter)
 32((function_call
 33   function: (identifier) @function)
 34 (#is-not? local))
 35((binary_expression
 36   operator: "|>"
 37   right: (identifier) @function)
 38 (#is-not? local))
 39
 40; "Properties"
 41; Assumed to be intended to refer to a name for a field; something that comes
 42; before ":" or after "."
 43; e.g. record field names, tuple indices, names for named arguments, etc
 44(label) @property
 45(tuple_access
 46  index: (integer) @property)
 47
 48; Attributes
 49(attribute
 50  "@" @attribute
 51  name: (identifier) @attribute)
 52
 53(attribute_value (identifier) @constant)
 54
 55; Type names
 56(remote_type_identifier) @type
 57(type_identifier) @type
 58
 59; Data constructors
 60(constructor_name) @constructor
 61
 62; Literals
 63(string) @string
 64((escape_sequence) @warning
 65 ; Deprecated in v0.33.0-rc2:
 66 (#eq? @warning "\\e"))
 67(escape_sequence) @string.escape
 68(bit_string_segment_option) @function.builtin
 69(integer) @number
 70(float) @number
 71
 72; Reserved identifiers
 73; TODO: when tree-sitter supports `#any-of?` in the Rust bindings,
 74; refactor this to use `#any-of?` rather than `#match?`
 75((identifier) @warning
 76 (#match? @warning "^(auto|delegate|derive|else|implement|macro|test|echo)$"))
 77
 78; Variables
 79(identifier) @variable
 80(discard) @comment.unused
 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