rust-lang / rust-lang/rust-analyzer
Distinguishing between different operators in semantic highlighting
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
Currently, rust-analyzer categorizes all operators as being of "operator" semantic token type. While this is very much according to the spec, it does make coloring different operators different colors impossible in semantic highlighting, which was not (and still is not) a problem with non-semantic syntax highlighting. Themes and token color customization settings cannot be used to work around this problem. The keyword.operator textmate blanket matching rule is used for operators in semantic highlighting, and such a rule is defined in the intrinsic base themes supplied with VS Code. Since semantic token coloring rules always override textmate coloring rules when semantic highlighting is enabled, this means that all operators are colored the same color according to some token coloring rule.
My proposal is to add custom semantic token modifiers to the different kinds of operators so that token coloring rules can selectively select some operators but not others, and color them as desired. I am not aware of any particular LSP language server that does this yet, but I would not be surprised to find out about ones that do this or are in the process of implementing such modifiers.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No specific files, tests, or entry points are named. Start by tracing rust-analyzer's semantic highlighting and LSP semantic token handling, then determine how operator categories could receive distinct modifiers. Done means different operator kinds can be selected and colored independently through semantic token rules without relying on textmate highlighting.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- developer-experience, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100