highlights.scm

  1(type_identifier) @type
  2(primitive_type) @type.builtin
  3(self) @variable.special
  4(field_identifier) @property
  5
  6(trait_item name: (type_identifier) @type.interface)
  7(impl_item trait: (type_identifier) @type.interface)
  8(abstract_type trait: (type_identifier) @type.interface)
  9(dynamic_type trait: (type_identifier) @type.interface)
 10(trait_bounds (type_identifier) @type.interface)
 11
 12(call_expression
 13  function: [
 14    (identifier) @function
 15    (scoped_identifier
 16      name: (identifier) @function)
 17    (field_expression
 18      field: (field_identifier) @function.method)
 19  ])
 20
 21(generic_function
 22  function: [
 23    (identifier) @function
 24    (scoped_identifier
 25      name: (identifier) @function)
 26    (field_expression
 27      field: (field_identifier) @function.method)
 28  ])
 29
 30(function_item name: (identifier) @function.definition)
 31(function_signature_item name: (identifier) @function.definition)
 32
 33(macro_invocation
 34  macro: [
 35    (identifier) @function.special
 36    (scoped_identifier
 37      name: (identifier) @function.special)
 38  ])
 39
 40(macro_definition
 41  name: (identifier) @function.special.definition)
 42
 43; Identifier conventions
 44
 45; Assume uppercase names are types/enum-constructors
 46((identifier) @type
 47 (#match? @type "^[A-Z]"))
 48
 49; Assume all-caps names are constants
 50((identifier) @constant
 51 (#match? @constant "^_*[A-Z][A-Z\\d_]*$"))
 52
 53[
 54  "("
 55  ")"
 56  "{"
 57  "}"
 58  "["
 59  "]"
 60] @punctuation.bracket
 61
 62(_
 63  .
 64  "<" @punctuation.bracket
 65  ">" @punctuation.bracket)
 66
 67[
 68  "as"
 69  "async"
 70  "await"
 71  "break"
 72  "const"
 73  "continue"
 74  "default"
 75  "dyn"
 76  "else"
 77  "enum"
 78  "extern"
 79  "fn"
 80  "for"
 81  "if"
 82  "impl"
 83  "in"
 84  "let"
 85  "loop"
 86  "macro_rules!"
 87  "match"
 88  "mod"
 89  "move"
 90  "pub"
 91  "ref"
 92  "return"
 93  "static"
 94  "struct"
 95  "trait"
 96  "type"
 97  "union"
 98  "unsafe"
 99  "use"
100  "where"
101  "while"
102  "yield"
103  (crate)
104  (mutable_specifier)
105  (super)
106] @keyword
107
108[
109  (string_literal)
110  (raw_string_literal)
111  (char_literal)
112] @string
113
114[
115  (integer_literal)
116  (float_literal)
117] @number
118
119(boolean_literal) @constant
120
121[
122  (line_comment)
123  (block_comment)
124] @comment