highlights.scm

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