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

Distinguishing between different operators in semantic highlighting #8279

Open
eaglgenes101 opened this issue Mar 31, 2021 · 2 comments
Open
Labels
A-highlighting (semantic) token highlighting S-actionable Someone could pick this issue up and work on it right now

Comments

@eaglgenes101
Copy link
Contributor

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.

@Veykril Veykril added the S-actionable Someone could pick this issue up and work on it right now label Mar 31, 2021
@Veykril
Copy link
Member

Veykril commented Mar 31, 2021

This is certainly something that would be nice, we did something similar for punctuation already.
See #6152 and the corresponding PR #6238.

Note that the LSP doesn't define inheritance relationships for semantic tokens, so this will cause general operator styling to not work unless the client defines such relationships itself. In case for VSCode this is possible to specify and we already do that for punctuation, so this would have to be adjusted for this to cover the new operator tokens then.

@Veykril
Copy link
Member

Veykril commented Apr 24, 2021

#8354 gave some more specific categories for operators namely:

  • bitwise
  • arithmetic
  • logical
  • comparison
  • operator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-highlighting (semantic) token highlighting S-actionable Someone could pick this issue up and work on it right now
Projects
None yet
Development

No branches or pull requests

2 participants