on ed950fc help sign in
helix/runtime/queries/python/highlights.scm
176 lines 3.4 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)
37(decorator (attribute attribute: (identifier) @function))
38(decorator (call
39 function: (attribute attribute: (identifier) @function)))
41; Parameters
43((identifier) @variable.builtin
44 (#match? @variable.builtin "^(self|cls)$"))
46(parameters (identifier) @variable.parameter)
47(parameters (typed_parameter (identifier) @variable.parameter))
48(parameters (default_parameter name: (identifier) @variable.parameter))
49(parameters (typed_default_parameter name: (identifier) @variable.parameter))
50(keyword_argument name: (identifier) @variable.parameter)
52; Types
54((identifier) @type.builtin
55 (#match?
56 @type.builtin
57 "^(bool|bytes|dict|float|frozenset|int|list|set|str|tuple)$"))
59; In type hints make everything types to catch non-conforming identifiers
60; (e.g., datetime.datetime) and None
61(type [(identifier) (none)] @type)
62; Handle [] . and | nesting 4 levels deep
63(type
64 (_ [(identifier) (none)]? @type
65 (_ [(identifier) (none)]? @type
66 (_ [(identifier) (none)]? @type
67 (_ [(identifier) (none)]? @type)))))
69(class_definition name: (identifier) @type)
70(class_definition superclasses: (argument_list (identifier) @type))
72; Variables
74((identifier) @constant
75 (#match? @constant "^[A-Z_]{2,}$"))
77((identifier) @type
78 (#match? @type "^[A-Z]"))
80(attribute attribute: (identifier) @variable.other.member)
81(identifier) @variable
83; Literals
86 (none)
87 (true)
88 (false)
89] @constant.builtin
91(integer) @constant.numeric.integer
92(float) @constant.numeric.float
93(comment) @comment
94(string) @string
95(escape_sequence) @constant.character.escape
97(interpolation
98 "{" @punctuation.special
99 "}" @punctuation.special) @embedded
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] @operator
135 "as"
136 "assert"
137 "await"
138 "break"
139 "continue"
140 "elif"
141 "else"
142 "except"
143 "finally"
144 "for"
145 "from"
146 "if"
147 "import"
148 "pass"
149 "raise"
150 "return"
151 "try"
152 "while"
153 "with"
154 "yield"
155] @keyword.control
157(for_statement "in" @keyword.control)
158(for_in_clause "in" @keyword.control)
161 "and"
162 "async"
163 "class"
164 "def"
165 "del"
166 "exec"
167 "global"
168 "in"
169 "is"
170 "lambda"
171 "nonlocal"
172 "not"
173 "or"
174 "print"
175] @keyword