highlights.scm

  1(parameter (identifier) @variable)
  2(attribute attribute: (identifier) @property)
  3(type (identifier) @type)
  4
  5; Module imports
  6
  7(import_statement
  8  (dotted_name (identifier) @type))
  9
 10(import_statement
 11  (aliased_import
 12    name: (dotted_name (identifier) @type)
 13    alias: (identifier) @type))
 14
 15(import_from_statement
 16  (dotted_name (identifier) @type))
 17
 18(import_from_statement
 19  (aliased_import
 20    name: (dotted_name (identifier) @type)
 21    alias: (identifier) @type))
 22
 23; Function calls
 24
 25(decorator) @function
 26
 27(call
 28  function: (attribute attribute: (identifier) @function.method))
 29(call
 30  function: (identifier) @function)
 31
 32; Function definitions
 33
 34(function_definition
 35  name: (identifier) @function)
 36
 37; Identifier naming conventions
 38
 39((identifier) @type
 40 (#match? @type "^[A-Z]"))
 41
 42((identifier) @constant
 43 (#match? @constant "^_*[A-Z][A-Z\\d_]*$"))
 44
 45; Builtin functions
 46
 47((call
 48  function: (identifier) @function.builtin)
 49 (#match?
 50   @function.builtin
 51   "^(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__)$"))
 52
 53; Literals
 54
 55[
 56  (none)
 57  (true)
 58  (false)
 59] @constant.builtin
 60
 61[
 62  (integer)
 63  (float)
 64] @number
 65
 66; Self references
 67
 68[
 69  (parameters (identifier) @variable.special)
 70  (attribute (identifier) @variable.special)
 71  (#match? @variable.special "^self$")
 72]
 73
 74(comment) @comment
 75(string) @string
 76(escape_sequence) @escape
 77
 78[
 79  "("
 80  ")"
 81  "["
 82  "]"
 83  "{"
 84  "}"
 85] @punctuation.bracket
 86
 87(interpolation
 88  "{" @punctuation.special
 89  "}" @punctuation.special) @embedded
 90
 91; Docstrings.
 92(function_definition
 93  "async"?
 94  "def"
 95  name: (_)
 96  (parameters)?
 97  body: (block (expression_statement (string) @string.doc)))
 98
 99[
100  "-"
101  "-="
102  "!="
103  "*"
104  "**"
105  "**="
106  "*="
107  "/"
108  "//"
109  "//="
110  "/="
111  "&"
112  "%"
113  "%="
114  "^"
115  "+"
116  "->"
117  "+="
118  "<"
119  "<<"
120  "<="
121  "<>"
122  "="
123  ":="
124  "=="
125  ">"
126  ">="
127  ">>"
128  "|"
129  "~"
130  "and"
131  "in"
132  "is"
133  "not"
134  "or"
135  "is not"
136  "not in"
137] @operator
138
139[
140  "as"
141  "assert"
142  "async"
143  "await"
144  "break"
145  "class"
146  "continue"
147  "def"
148  "del"
149  "elif"
150  "else"
151  "except"
152  "exec"
153  "finally"
154  "for"
155  "from"
156  "global"
157  "if"
158  "import"
159  "lambda"
160  "nonlocal"
161  "pass"
162  "print"
163  "raise"
164  "return"
165  "try"
166  "while"
167  "with"
168  "yield"
169  "match"
170  "case"
171] @keyword