Highlight instance vars, method defs, and keyword params distinctly#298
Open
orthodoX wants to merge 1 commit into
Open
Highlight instance vars, method defs, and keyword params distinctly#298orthodoX wants to merge 1 commit into
orthodoX wants to merge 1 commit into
Conversation
These three constructs are folded into broader shared captures, so themes cannot color them independently: - instance variables share `@variable.special` with `self`, `super`, and class variables - method definitions share `@function.method` with method calls - keyword parameters share `@variable.parameter` with positional parameters Give each its own dotted sub-scope, following the sub-scoping convention already used throughout this file (e.g. `function.method.builtin`, `keyword.control.conditional`, `string.special.symbol`): - (instance_variable) -> @variable.special.instance - method / singleton_method -> @function.method.definition - keyword_parameter -> @variable.parameter.keyword Fully backwards-compatible: Zed resolves highlight names by longest prefix, so themes that only define `variable.special`, `function.method`, or `variable.parameter` render these exactly as before. Themes can now opt in to distinguishing them.
|
We require contributors to sign our Contributor License Agreement, and we don't have @orthodoX on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'. |
Author
|
@cla-bot check |
|
The cla-bot has been summoned, and re-checked this pull request! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Coming from VSCode/Cursor ecosystem, I really miss these semantic token modifiers:
@foo)@variable.specialself,super, class variablesdef foo)@function.methoddef m(foo:))@variable.parameterThese are exactly the distinctions many editors/themes expose (e.g. VS Code separates a method declaration from a method call via semantic token modifiers), but here the grammar collapses them, so the information needed to theme them is thrown away before it ever reaches the theme layer.
self,super, and class variables intentionally stay on@variable.special; method calls stay on@function.method; positional params stay on@variable.parameter.Backwards compatibility
This PR is purely additive: existing themes are unaffected, and theme authors gain three new opt-in targets.
Consistency with existing conventions
The new names follow the dotted sub-scoping already used throughout this file.
How a theme author opts in
Screenshots
Before
After