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(comment) @comment
 48(string) @string
 49(escape_sequence) @escape
 50
 51(interpolation
 52  "{" @punctuation.special
 53  "}" @punctuation.special) @embedded
 54
 55; Docstrings.
 56(function_definition
 57  "async"?
 58  "def"
 59  name: (_)
 60  (parameters)?
 61  body: (block (expression_statement (string) @string.doc)))
 62
 63[
 64  "-"
 65  "-="
 66  "!="
 67  "*"
 68  "**"
 69  "**="
 70  "*="
 71  "/"
 72  "//"
 73  "//="
 74  "/="
 75  "&"
 76  "%"
 77  "%="
 78  "^"
 79  "+"
 80  "->"
 81  "+="
 82  "<"
 83  "<<"
 84  "<="
 85  "<>"
 86  "="
 87  ":="
 88  "=="
 89  ">"
 90  ">="
 91  ">>"
 92  "|"
 93  "~"
 94  "and"
 95  "in"
 96  "is"
 97  "not"
 98  "or"
 99] @operator
100
101[
102  "as"
103  "assert"
104  "async"
105  "await"
106  "break"
107  "class"
108  "continue"
109  "def"
110  "del"
111  "elif"
112  "else"
113  "except"
114  "exec"
115  "finally"
116  "for"
117  "from"
118  "global"
119  "if"
120  "import"
121  "lambda"
122  "nonlocal"
123  "pass"
124  "print"
125  "raise"
126  "return"
127  "try"
128  "while"
129  "with"
130  "yield"
131  "match"
132  "case"
133] @keyword