|
| 1 | +; Punctuation |
| 2 | + |
| 3 | +["," "." ":" ";" (ellipsis)] @punctuation.delimiter |
| 4 | +["(" ")" "[" "]" "{" "}"] @punctuation.bracket |
| 5 | +(interpolation |
| 6 | + "{" @punctuation.special |
| 7 | + "}" @punctuation.special) |
| 8 | + |
| 9 | +; Identifier naming conventions |
| 10 | + |
| 11 | +(identifier) @variable |
| 12 | + |
| 13 | +((identifier) @constructor |
| 14 | + (#match? @constructor "^[A-Z]")) |
| 15 | + |
| 16 | +((identifier) @constant |
| 17 | + (#match? @constant "^[A-Z][A-Z_]*$")) |
| 18 | + |
| 19 | +; Function calls |
| 20 | + |
| 21 | +(decorator) @function |
| 22 | + |
| 23 | +(call |
| 24 | + function: (attribute attribute: (identifier) @function.method)) |
| 25 | +(call |
| 26 | + function: (identifier) @function) |
| 27 | + |
| 28 | +; Builtin functions |
| 29 | + |
| 30 | +((call |
| 31 | + function: (identifier) @function.builtin) |
| 32 | + (#any-of? |
| 33 | + @function.builtin |
| 34 | + "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__")) |
| 35 | + |
| 36 | +; Types |
| 37 | + |
| 38 | +(maybe_typed_name |
| 39 | + type: ((_) @type)) |
| 40 | + |
| 41 | +(type |
| 42 | + (identifier) @type) |
| 43 | + |
| 44 | +(c_type |
| 45 | + type: ((_) @type)) |
| 46 | +(c_type |
| 47 | + ((identifier) @type)) |
| 48 | +(c_type |
| 49 | + ((int_type) @type)) |
| 50 | + |
| 51 | +(maybe_typed_name |
| 52 | + name: ((identifier) @variable)) |
| 53 | + |
| 54 | +; Function definitions |
| 55 | + |
| 56 | +(function_definition |
| 57 | + name: (identifier) @function) |
| 58 | + |
| 59 | +(cdef_statement |
| 60 | + (cvar_def |
| 61 | + (maybe_typed_name |
| 62 | + name: ((identifier) @function)) |
| 63 | + (c_function_definition))) |
| 64 | + |
| 65 | +(cvar_decl |
| 66 | + (c_type |
| 67 | + ([(identifier) (int_type)])) |
| 68 | + (c_name |
| 69 | + ((identifier) @function)) |
| 70 | + (c_function_definition)) |
| 71 | + |
| 72 | +(attribute attribute: (identifier) @variable.other.member) |
| 73 | + |
| 74 | +; Literals |
| 75 | + |
| 76 | +[ |
| 77 | + (none) |
| 78 | +] @constant.builtin |
| 79 | + |
| 80 | +[ |
| 81 | + (true) |
| 82 | + (false) |
| 83 | +] @constant.builtin.boolean |
| 84 | + |
| 85 | +(integer) @constant.numeric.integer |
| 86 | +(float) @constant.numeric.float |
| 87 | + |
| 88 | +(comment) @comment |
| 89 | +(string) @string |
| 90 | +(escape_sequence) @constant.character.escape |
| 91 | + |
| 92 | +(interpolation |
| 93 | + "{" @punctuation.special |
| 94 | + "}" @punctuation.special) @embedded |
| 95 | + |
| 96 | +[ |
| 97 | + "-" |
| 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 | + "|=" |
| 131 | + "~" |
| 132 | + "@=" |
| 133 | + "and" |
| 134 | + "in" |
| 135 | + "is" |
| 136 | + "not" |
| 137 | + "or" |
| 138 | + "@" |
| 139 | +] @operator |
| 140 | + |
| 141 | +[ |
| 142 | + "as" |
| 143 | + "assert" |
| 144 | + "async" |
| 145 | + "await" |
| 146 | + "break" |
| 147 | + "class" |
| 148 | + "continue" |
| 149 | + "def" |
| 150 | + "del" |
| 151 | + "elif" |
| 152 | + "else" |
| 153 | + "except" |
| 154 | + "exec" |
| 155 | + "finally" |
| 156 | + "for" |
| 157 | + "from" |
| 158 | + "global" |
| 159 | + "if" |
| 160 | + "import" |
| 161 | + "lambda" |
| 162 | + "nonlocal" |
| 163 | + "pass" |
| 164 | + "print" |
| 165 | + "raise" |
| 166 | + "return" |
| 167 | + "try" |
| 168 | + "while" |
| 169 | + "with" |
| 170 | + "yield" |
| 171 | + "match" |
| 172 | + "case" |
| 173 | + |
| 174 | + ; cython-specific |
| 175 | + "cdef" |
| 176 | + "cpdef" |
| 177 | + "ctypedef" |
| 178 | + "cimport" |
| 179 | + "nogil" |
| 180 | + "gil" |
| 181 | + "extern" |
| 182 | + "inline" |
| 183 | + "public" |
| 184 | + "readonly" |
| 185 | + "struct" |
| 186 | + "union" |
| 187 | + "enum" |
| 188 | + "fused" |
| 189 | + "property" |
| 190 | + "namespace" |
| 191 | + "cppclass" |
| 192 | + "const" |
| 193 | +] @keyword.control |
| 194 | + |
| 195 | +(dotted_name |
| 196 | + (identifier)* @namespace) |
| 197 | + |
| 198 | +(aliased_import |
| 199 | + alias: (identifier) @namespace) |
0 commit comments