Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax highlight and indent Python match case statements #4526

Closed
sudormrfbin opened this issue Oct 30, 2022 · 2 comments · Fixed by #4560
Closed

Syntax highlight and indent Python match case statements #4526

sudormrfbin opened this issue Oct 30, 2022 · 2 comments · Fixed by #4560
Labels
A-tree-sitter Area: Tree-sitter C-enhancement Category: Improvements E-easy Call for participation: Experience needed to fix: Easy / not much E-has-instructions Call for participation: Has instructions for fixing the issue and opening a PR

Comments

@sudormrfbin
Copy link
Member

Python's pattern matching syntax using match and case is not properly highlighted due to missing highlight queries. match and case can be assigned to @keyword.control:

[
"as"
"assert"
"await"
"from"
"pass"
"with"
] @keyword.control

The tree-sitter grammar might have additional nodes that can be highlighted.

@sudormrfbin sudormrfbin added C-enhancement Category: Improvements E-easy Call for participation: Experience needed to fix: Easy / not much A-tree-sitter Area: Tree-sitter E-has-instructions Call for participation: Has instructions for fixing the issue and opening a PR labels Oct 30, 2022
@sudormrfbin sudormrfbin changed the title Syntax highlight Python match case statements Syntax highlight and indent Python match case statements Oct 30, 2022
@sudormrfbin
Copy link
Member Author

Indent queries will also have to added to the indents.scm file. The tree-sitter node names can be obtained from the grammar.

@ygabuev
Copy link
Contributor

ygabuev commented Nov 1, 2022

@sudormrfbin don't you think is should rather be @keyword.control.conditional as is match in rust:

[
"match"
"if"
"else"
] @keyword.control.conditional

and switch and case in c:
[
"if"
"else"
"switch"
"case"
"default"
] @keyword.control.conditional

?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tree-sitter Area: Tree-sitter C-enhancement Category: Improvements E-easy Call for participation: Experience needed to fix: Easy / not much E-has-instructions Call for participation: Has instructions for fixing the issue and opening a PR
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants