rust-lang / rust-lang/rust-analyzer

Distinguishing between different operators in semantic highlighting

Open
#8,279 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-highlighting S-actionable
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.