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

Add semantic token modifiers for punctuation #6152

Closed
Veetaha opened this issue Oct 6, 2020 · 6 comments · Fixed by #6238
Closed

Add semantic token modifiers for punctuation #6152

Veetaha opened this issue Oct 6, 2020 · 6 comments · Fixed by #6238
Labels
E-medium S-actionable Someone could pick this issue up and work on it right now

Comments

@Veetaha
Copy link
Contributor

Veetaha commented Oct 6, 2020

I used to have different colors for curly braces, operators, parens, brackets and other punctuation in TypeScript.

Take this colorization as an example:

image

It is not possible to achieve this amount of color diversity for punctuation in rust-analyzer for now, so I propose to add more specific semantic token modifiers for punctuation: punctuation.curlyBrace, punctuation.bracket, punctuation.paren ... so that it is possible to control the style of each individual punctuation symbol kind.

I am not insisting on implementing this via semantic token modifiers, this is just the first thing that comes to my head.

@Veykril
Copy link
Member

Veykril commented Oct 6, 2020

I believe that textmate scopes for these would be a better fit, since punctuations don't really have any semantic meaning in this case and you can use textmate scopes just fine with semantic highlighting enabled, as it falls back in those cases where it isn't used for tokens.

@Veetaha
Copy link
Contributor Author

Veetaha commented Oct 7, 2020

TextMate might work too, but our TextMate doesn't produce dedicated scopes for different punctuation symbols:
image

cc #6137

@Veykril
Copy link
Member

Veykril commented Oct 7, 2020

Yes those would have to be split up into multiple categories, would go well with that open PR right now I guess 😄

@dustypomerleau
Copy link
Contributor

Some semantic highlighting approaches ignore punctuation, which allows the underlying TextMate scopes to shine through. But this is not the case with RA, so with semantic highlighting enabled, the color of all bracket types will be whatever color the theme sets for punctuation:rust. There is a separate semantic token type for operator:rust, but that would be the only distinction. If you are willing to disable semantic highlighting, then yes, my open PR would allow you to theme all of those things separately.

@Veykril
Copy link
Member

Veykril commented Oct 8, 2020

Oh interesting, now that you say it there is a punctuation semantic rule. I guess I missed that when i checked earlier probably cause i was putting my cursor at the wrong position. Then yes textmate scopes wouldn't necessarily be helpful here.

@matklad
Copy link
Member

matklad commented Oct 14, 2020

Agree we should do this. Perfect rust-analyzer client wouldn't have text mate scopes at all, and would rely solely on semantic tokens.

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

Successfully merging a pull request may close this issue.

4 participants