-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
python: Refine highlighting #21389
python: Refine highlighting #21389
Conversation
Generic highlights should be higher up in the file in case they are conditionally overwritten by more specific rules below.
These assignments are effectively a subset of expression_statements where `type X = Y` and are often documented using docstrings.
Hi @JaagupAverin, I have some issues around Syntax Highlighting too. Review and change it, if you find it right.
Thank You! |
|
The way this is done elsewhere (nvim-treesitter) is by adding the following to ((comment) @injection.content
(#set! injection.language "comment")) And then https://github.com/stsewd/tree-sitter-comment (which syntax highlights those kind of TODO comments) is added under the "comment" language name, so injected for comments as such. This currently isn't standard practice in Zed though. See #9082 (comment) and #11895. |
I believe
I believe |
@uncenter |
This is correct. Themes support capturing any arbitrary capture. The table in the documentation is a list of common captures. See Helix's list of scopes: https://docs.helix-editor.com/themes.html?highlight=inherits#syntax-highlighting. And Neovim's, which is probably the most comprehensive: https://neovim.io/doc/user/treesitter.html#treesitter-highlight-groups.
Definitely. I'll try to tackle updating it at some point soon :)
Captures should not be language specific really, they are supposed to be general (though it should be possible to scope a general capture for a theme to match for just one language, see #9461 (comment)).
I believe |
Ok, Thanks for responding and correcting my comment @JaagupAverin and @uncenter. Above @JaagupAverin mentioned about semantic tokens highlighting through LSP, specifically |
I added one more commit for classifying keyword operators as |
Can you elaborate? That list of queries for variable parameters seems fine to me fwiw. |
There's one where any 2nd argument to
There's another that tries to fix what I believe is a bug in the python tree-sitter. This workaround won't always work since it could have several kinds of parents, not just
btw the only reason I picked these out was because I have been trying to solve the same issues here, but came to the conclusion that they're not worth the special handling. |
Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com>
Thanks! |
I've just noticed that there's a bunch of unresolved questions in this thread; I feel like these can be tackled in a separate PR. |
Fixes:
except*
keyword not highlighted;_
not recognized as such, however_
is a valid first character for private classes; additionally the regex for parsing constant/class names appeared inconsistent and incomplete so was adjusted;float
,dict
, etc not recognized as types;and/in/is/not/or/is not/not in
not capturable as keywords;Before:

After:

Release Notes: