This repository was archived by the owner on Dec 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 147
/
Copy pathtree-sitter-python.cson
198 lines (175 loc) · 6.88 KB
/
tree-sitter-python.cson
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
name: 'Python'
scopeName: 'source.python'
type: 'tree-sitter'
parser: 'tree-sitter-python'
firstLineRegex: [
# shebang line
'^#![ \\t]*/.*\\bpython[\\d\\.]*\\b'
# vim modeline
'vim\\b.*\\bset\\b.*\\b(filetype|ft|syntax)=python'
]
fileTypes: [
'py'
'pyi'
'pyw'
'gyp'
'gypi'
'SConstruct'
'Sconstruct'
'sconstruct'
'SConscript'
'wsgi'
]
folds: [
{
type: ['if_statement']
start: {type: ':'}
end: {type: ['elif_clause', 'else_clause']}
},
{
type: [
'if_statement'
'elif_clause'
'else_clause'
'for_statement'
'try_statement'
'with_statement'
'while_statement'
'class_definition'
'function_definition'
'async_function_definition'
]
start: {type: ':'}
},
{
start: {type: '(', index: 0}
end: {type: ')', index: -1}
},
{
start: {type: '[', index: 0}
end: {type: ']', index: -1}
},
{
start: {type: '{', index: 0}
end: {type: '}', index: -1}
}
]
comments:
start: '# '
scopes:
'module': 'source.python'
'comment': 'comment.line'
'string': 'string.quoted'
'escape_sequence': 'constant.character.escape'
'interpolation': 'meta.embedded'
'interpolation > "{"': 'punctuation.section.embedded'
'interpolation > "}"': 'punctuation.section.embedded'
'class_definition > identifier': 'entity.name.type.class'
'function_definition > identifier': 'entity.name.function.definition'
'call > identifier:nth-child(0)': [
{match: '^(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__)$',
scopes: 'support.function.call'},
{match: '^[A-Z]', scopes: 'support.type.contructor'}
'entity.name.function.call'
]
'call > attribute > identifier:nth-child(2)': 'entity.name.function'
'identifier': [
{match:
'^(BaseException|Exception|TypeError|StopAsyncIteration|StopIteration|ImportError|ModuleNotFoundError|OSError|ConnectionError|BrokenPipeError|ConnectionAbortedError|ConnectionRefusedError|ConnectionResetError|BlockingIOError|ChildProcessError|FileExistsError|FileNotFoundError|IsADirectoryError|NotADirectoryError|InterruptedError|PermissionError|ProcessLookupError|TimeoutError|EOFError|RuntimeError|RecursionError|NotImplementedError|NameError|UnboundLocalError|AttributeError|SyntaxError|IndentationError|TabError|LookupError|IndexError|KeyError|ValueError|UnicodeError|UnicodeEncodeError|UnicodeDecodeError|UnicodeTranslateError|AssertionError|ArithmeticError|FloatingPointError|OverflowError|ZeroDivisionError|SystemError|ReferenceError|BufferError|MemoryError|Warning|UserWarning|DeprecationWarning|PendingDeprecationWarning|SyntaxWarning|RuntimeWarning|FutureWarning|ImportWarning|UnicodeWarning|BytesWarning|ResourceWarning|GeneratorExit|SystemExit|KeyboardInterrupt)$'
scopes: 'support.type.exception'},
{match: '^(self)', scopes: 'entity.name.variable.self'}
]
'attribute > identifier:nth-child(2)': 'variable.other.object.property'
'decorator': 'entity.name.function.decorator'
'none': 'constant.language'
'true': 'constant.language'
'false': 'constant.language'
'integer': 'constant.numeric'
'float': 'constant.numeric'
'"..."': 'constant.ellipsis.other'
'type > identifier': 'support.storage.type'
'class_definition > argument_list > attribute': 'entity.other.inherited-class'
'class_definition > argument_list > identifier': 'entity.other.inherited-class'
'class_definition > argument_list > keyword_argument > attribute': 'entity.other.inherited-class'
'class_definition > argument_list > keyword_argument > identifier:nth-child(2)': 'entity.other.inherited-class'
'"class"': 'storage.type.class'
'"def"': 'storage.type.function'
'"lambda"': 'storage.type.function'
'"global"': 'storage.modifier.global'
'"nonlocal"': 'storage.modifier.nonlocal'
'parameters > identifier': 'variable.parameter.function'
'parameters > list_splat > identifier': 'variable.parameter.function'
'parameters > dictionary_splat > identifier': 'variable.parameter.function'
'default_parameter > identifier:nth-child(0)': 'variable.parameter.function'
'keyword_argument > identifier:nth-child(0)': 'variable.parameter.function'
'lambda_parameters > identifier': 'variable.parameter.function'
'typed_parameter > identifier': 'variable.parameter.function'
'argument_list': 'meta.method-call.python'
'"if"': 'keyword.control'
'"else"': 'keyword.control'
'"elif"': 'keyword.control'
'"while"': 'keyword.control'
'"for"': 'keyword.control'
'"return"': 'keyword.control'
'"break"': 'keyword.control'
'"continue"': 'keyword.control'
'"pass"': 'keyword.control'
'"raise"': 'keyword.control'
'"yield"': 'keyword.control'
'"await"': 'keyword.control'
'"async"': 'keyword.control'
'"try"': 'keyword.control'
'"except"': 'keyword.control'
'"with"': 'keyword.control'
'"as"': 'keyword.control'
'"finally"': 'keyword.control'
'"import"': 'keyword.control'
'"from"': 'keyword.control'
'"print"': 'keyword.other'
'"assert"': 'keyword.other'
'"exec"': 'keyword.other'
'"del"': 'keyword.other'
'"+"': 'keyword.operator'
'"-"': 'keyword.operator'
'"*"': 'keyword.operator'
'"/"': 'keyword.operator'
'"%"': 'keyword.operator'
'"**"': 'keyword.operator'
'"//"': 'keyword.operator'
'"=="': 'keyword.operator'
'"!="': 'keyword.operator'
'"<>"': 'keyword.operator'
'">"': 'keyword.operator'
'"<"': 'keyword.operator'
'">="': 'keyword.operator'
'"<="': 'keyword.operator'
'"="': 'keyword.operator'
'"+="': 'keyword.operator'
'"-="': 'keyword.operator'
'"*="': 'keyword.operator'
'"/="': 'keyword.operator'
'"%="': 'keyword.operator'
'"**="': 'keyword.operator'
'"//="': 'keyword.operator'
'"&"': 'keyword.operator'
'"|"': 'keyword.operator'
'"^"': 'keyword.operator'
'"~"': 'keyword.operator'
'"<<"': 'keyword.operator'
'">>"': 'keyword.operator'
'binary_operator > "@"': 'keyword.operator'
'binary_operator > "@="': 'keyword.operator'
'"in"': 'keyword.operator.logical.python'
'"and"': 'keyword.operator.logical.python'
'"or"': 'keyword.operator.logical.python'
'"not"': 'keyword.operator.logical.python'
'"is"': 'keyword.operator.logical.python'
'"->"': 'keyword.operator.function-annotation'
'":"': 'punctuation.separator'
'"["': 'punctuation.definition.begin.bracket.square'
'"]"': 'punctuation.definition.end.bracket.square'
'","': 'punctuation.separator.delimiter'
'"{"': 'punctuation.section.block.begin.bracket.curly'
'"}"': 'punctuation.section.block.end.bracket.curly'
'"("': 'punctuation.section.parens.begin.bracket.round'
'")"': 'punctuation.section.parens.end.bracket.round'