on abef250 help sign in
helix/runtime/queries/python/highlights.scm
170 lines 3.1 kB history raw
1; Builtin functions
3((call
4 function: (identifier) @function.builtin)
5 (#match?
6 @function.builtin
7 "^(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__)$"))
9; Function calls
11(call
12 function: (attribute attribute: (identifier) @constructor)
13 (#match? @constructor "^[A-Z]"))
14(call
15 function: (identifier) @constructor
16 (#match? @constructor "^[A-Z]"))
18(call
19 function: (attribute attribute: (identifier) @function.method))
21(call
22 function: (identifier) @function)
24; Function definitions
26(function_definition
27 name: (identifier) @constructor
28 (#match? @constructor "^(__new__|__init__)$"))
30(function_definition
31 name: (identifier) @function)
33; Decorators
35(decorator) @function
36(decorator (identifier) @function)
38; Parameters
40((identifier) @variable.builtin
41 (#match? @variable.builtin "^(self|cls)$"))
43(parameters (identifier) @variable.parameter)
44(parameters (typed_parameter (identifier) @variable.parameter))
46; Types
48((identifier) @type.builtin
49 (#match?
50 @type.builtin
51 "^(bool|bytes|dict|float|frozenset|int|list|set|str|tuple)$"))
53; In type hints make everything types to catch non-conforming identifiers
54; (e.g., datetime.datetime) and None
55(type [(identifier) (none)] @type)
56; Handle [] . and | nesting 4 levels deep
57(type
58 (_ [(identifier) (none)]? @type
59 (_ [(identifier) (none)]? @type
60 (_ [(identifier) (none)]? @type
61 (_ [(identifier) (none)]? @type)))))
63(class_definition name: (identifier) @type)
64(class_definition superclasses: (argument_list (identifier) @type))
66; Variables
68((identifier) @constant
69 (#match? @constant "^[A-Z_]{2,}$"))
71((identifier) @type
72 (#match? @type "^[A-Z]"))
74(attribute attribute: (identifier) @variable.other.member)
75(identifier) @variable
77; Literals
80 (none)
81 (true)
82 (false)
83] @constant.builtin
85(integer) @constant.numeric.integer
86(float) @constant.numeric.float
87(comment) @comment
88(string) @string
89(escape_sequence) @constant.character.escape
91(interpolation
92 "{" @punctuation.special
93 "}" @punctuation.special) @embedded
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] @operator
129 "as"
130 "assert"
131 "await"
132 "break"
133 "continue"
134 "elif"
135 "else"
136 "except"
137 "finally"
138 "for"
139 "from"
140 "if"
141 "import"
142 "pass"
143 "raise"
144 "return"
145 "try"
146 "while"
147 "with"
148 "yield"
149] @keyword.control
151(for_statement "in" @keyword.control)
152(for_in_clause "in" @keyword.control)
155 "and"
156 "async"
157 "class"
158 "def"
159 "del"
160 "exec"
161 "global"
162 "in"
163 "is"
164 "lambda"
165 "nonlocal"
166 "not"
167 "or"
168 "print"
169] @keyword