Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Update tree-sitter-python + Add missing tree-sitter scopes #325

Merged
merged 14 commits into from
Jan 27, 2021
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ git:

sudo: false

dist: trusty
dist: bionic

addons:
apt:
Expand Down
26 changes: 21 additions & 5 deletions grammars/tree-sitter-python.cson
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,21 @@ scopes:
'interpolation > "}"': 'punctuation.section.embedded'

'class_definition > identifier': 'entity.name.type.class'
'function_definition > identifier': 'entity.name.function'
'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'},
'entity.name.function'
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':
'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'}
scopes: 'support.type.exception'},
{match: '^(self)', scopes: 'entity.name.variable.self'}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs ^(self)\\b otherwise it'll match the self in selfserve and other things

]

'attribute > identifier:nth-child(2)': 'variable.other.object.property'

Expand Down Expand Up @@ -115,6 +118,10 @@ scopes:
'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'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why .function is on there (aren't parameters always part of a function?)


'argument_list': 'meta.method-call.python'

'"if"': 'keyword.control'
'"else"': 'keyword.control'
Expand Down Expand Up @@ -177,3 +184,12 @@ scopes:
'"or"': 'keyword.operator.logical.python'
'"not"': 'keyword.operator.logical.python'
'"is"': 'keyword.operator.logical.python'
'"->"': 'keyword.control.return'

'"["': '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'
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
},
"dependencies": {
"atom-grammar-test": "^0.6.4",
"tree-sitter-python": "^0.15.1"
"tree-sitter-python": "^0.17.0"
},
"devDependencies": {
"coffeelint": "^1.10.1"
Expand Down