@@ -1,44 +1,78 @@
1−; Identifier naming conventions
2−
3−((identifier) @constant
4− (#match? @constant "^[A-Z_]*$"))
5−
6−((identifier) @constructor
7− (#match? @constructor "^[A-Z]"))
8−
9−; Types
10−
11−((identifier) @type
12− (#match?
13− @type
14− "^(bool|bytes|dict|float|frozenset|int|list|set|str|tuple)$"))
15−
16−(type (identifier)) @type
17−
181; Builtin functions
192
203((call
214 function: (identifier) @function.builtin)
225 (#match?
236 @function.builtin
24− "^(abs|all|any|ascii|bin|breakpoint|bytearray|callable|chr|classmethod|compile|complex|delattr|dir|divmod|enumerate|eval|exec|filter|format|getattr|globals|hasattr|hash|help|hex|id|input|isinstance|issubclass|iter|len|locals|map|max|memoryview|min|next|object|oct|open|ord|pow|print|property|range|repr|reversed|round|setattr|slice|sorted|staticmethod|sum|super|type|vars|zip|__import__)$"))
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__)$"))
258
269; Function calls
2710
28−(decorator) @function
11+(call
12+ function: (attribute attribute: (identifier) @constructor)
13+ (#match? @constructor "^[A-Z]"))
14+(call
15+ function: (identifier) @constructor
16+ (#match? @constructor "^[A-Z]"))
2917
3018(call
3119 function: (attribute attribute: (identifier) @function.method))
20+
3221(call
3322 function: (identifier) @function)
3423
3524; Function definitions
3625
26+(function_definition
27+ name: (identifier) @constructor
28+ (#match? @constructor "^(__new__|__init__)$"))
29+
3730(function_definition
3831 name: (identifier) @function)
3932
40−(identifier) @variable
33+; Decorators
34+
35+(decorator) @function
36+(decorator (identifier) @function)
37+
38+; Parameters
39+
40+((identifier) @variable.builtin
41+ (#match? @variable.builtin "^(self|cls)$"))
42+
43+(parameters (identifier) @variable.parameter)
44+(parameters (typed_parameter (identifier) @variable.parameter))
45+
46+; Types
47+
48+((identifier) @type.builtin
49+ (#match?
50+ @type.builtin
51+ "^(bool|bytes|dict|float|frozenset|int|list|set|str|tuple)$"))
52+
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)))))
62+
63+(class_definition name: (identifier) @type)
64+(class_definition superclasses: (argument_list (identifier) @type))
65+
66+; Variables
67+
68+((identifier) @constant
69+ (#match? @constant "^[A-Z_]{2,}$"))
70+
71+((identifier) @type
72+ (#match? @type "^[A-Z]"))
73+
4174(attribute attribute: (identifier) @variable.other.member)
75+(identifier) @variable
4276
4377; Literals
4478