highlights.scm

  1(attribute attribute: (identifier) @property)
  2(type (identifier) @type)
  3
  4; Function calls
  5
  6(decorator) @function
  7
  8(call
  9  function: (attribute attribute: (identifier) @function.method))
 10(call
 11  function: (identifier) @function)
 12
 13; Function definitions
 14
 15(function_definition
 16  name: (identifier) @function)
 17
 18; Identifier naming conventions
 19
 20((identifier) @type
 21 (#match? @type "^[A-Z]"))
 22
 23((identifier) @constant
 24 (#match? @constant "^_*[A-Z][A-Z\\d_]*$"))
 25
 26; Builtin functions
 27
 28((call
 29  function: (identifier) @function.builtin)
 30 (#match?
 31   @function.builtin
 32   "^(abs|all|any|ascii|bin|bool|breakpoint|bytearray|bytes|callable|chr|classmethod|compile|complex|delattr|dict|dir|divmod|enumerate|eval|exec|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|isinstance|issubclass|iter|len|list|locals|map|max|memoryview|min|next|object|oct|open|ord|pow|print|property|range|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|vars|zip|__import__)$"))
 33
 34; Literals
 35
 36[
 37  (none)
 38  (true)
 39  (false)
 40] @constant.builtin
 41
 42[
 43  (integer)
 44  (float)
 45] @number
 46
 47; Variables
 48(assignment
 49  left: (identifier) @variable)
 50
 51(comment) @comment
 52(string) @string
 53(escape_sequence) @escape
 54
 55[
 56  "("
 57  ")"
 58  "["
 59  "]"
 60  "{"
 61  "}"
 62] @punctuation.bracket
 63
 64(interpolation
 65  "{" @punctuation.special
 66  "}" @punctuation.special) @embedded
 67
 68; Docstrings.
 69(function_definition
 70  "async"?
 71  "def"
 72  name: (_)
 73  (parameters)?
 74  body: (block (expression_statement (string) @string.doc)))
 75
 76[
 77  "-"
 78  "-="
 79  "!="
 80  "*"
 81  "**"
 82  "**="
 83  "*="
 84  "/"
 85  "//"
 86  "//="
 87  "/="
 88  "&"
 89  "%"
 90  "%="
 91  "^"
 92  "+"
 93  "->"
 94  "+="
 95  "<"
 96  "<<"
 97  "<="
 98  "<>"
 99  "="
100  ":="
101  "=="
102  ">"
103  ">="
104  ">>"
105  "|"
106  "~"
107  "and"
108  "in"
109  "is"
110  "not"
111  "or"
112  "is not"
113  "not in"
114] @operator
115
116[
117  "as"
118  "assert"
119  "async"
120  "await"
121  "break"
122  "class"
123  "continue"
124  "def"
125  "del"
126  "elif"
127  "else"
128  "except"
129  "exec"
130  "finally"
131  "for"
132  "from"
133  "global"
134  "if"
135  "import"
136  "lambda"
137  "nonlocal"
138  "pass"
139  "print"
140  "raise"
141  "return"
142  "try"
143  "while"
144  "with"
145  "yield"
146  "match"
147  "case"
148] @keyword