-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Enhanced coloring #4400
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
Enhanced coloring #4400
Conversation
Coincidentally I ran into a similar issue myself in #4399. Is there a reason we don't use |
@CryZe |
2c7e426
to
8daa4e2
Compare
I don't think they need to match. Attributes are annotations, not macros. The only thing they have in common with Wouldn't this PR remove the ability to color attributes differently from keywords? I certainly don't want attributes to look like keywords. I hope that neither this PR nor the other one are making changes to the TM scopes that reduce the ability to customize the highlighting. You can always build a theme that gives multiple scopes the same color, but you can't use multiple colors if the items have the same scope. Apologies if I'm coming across a little defensively, but I'm pretty happy with my current syntax coloring and I don't want to see it become impossible due to the changes here. |
@aloucks Let's focus on #4397 for the moment, which is designed to be a non-controversial fix that prevents semantic coloring from "fighting" with textmate coloring. I agree with your point that if we do make any changes to scopes, we should make sure to use distinct scopes so it doesn't take away the ability to customize. You might think that rust-analyzer should just not concern itself with VSCode's default rust syntax coloring, but now that it's doing semantic coloring, it is arguably necessary to take "ownership" of the default theme to keep it in sync with semantic colors, or users will see weird changes when they open Rust files. |
@georgewfraser could you rebase? Seems like GH is having trouble picking up the correct diff here |
8daa4e2
to
1b344e9
Compare
@matklad I rebased. I also removed coloring attributes for now. It's potentially controversial, I'll make a new PR where we can have a more extensive discussion about what we could do or not do there. |
I definitively love the approach here of lowering semantic scopes to completely wrong text mate scopes to get basically a css class :D I do think we should do this for |
Think of TextMate as a giant mountain of cruft, upon which we are carefully perching an elegant foundation of semantic coloring 😄 The key idea is that we must not let the cruftiness of TextMate infect the semantic scopes---the semantic scopes should all be sensible, and then there's this layer of fallback scopes that translates down to the TextMate craziness. I think your point is reasonable about statics. Plus, I think it makes sense to make additions slowly and see how people react. If we're not "using" italic for statics, what do you think about underline vs italic for mutables? Italic is a lot more subtle, which is good or bad depending on your POV. |
Definitely unreling italics is too subtle. I've been using myself (I run a cusom theme) and that's what is used in IntellijJ as well. bors d+ |
✌️ georgewfraser can now approve this pull request. To approve and merge a pull request, simply reply with |
bors r+ |
Merge conflict. |
29e18cc
to
6222f2b
Compare
@georgewfraser do you want to merge this? :-) |
bors r+ |
Build succeeded: |
It might be worth doing the same distinction for |
@Xanewok Right now we're using the
We're using
|
Can the underlines be deactivated? |
@anderejd It should be possible...wasn't able to figure it out in a few minutes but will take another look as soon as I can. |
Ok thanks for looking into it. For now I edited the package.json for the vscode extension locally and that seems to work fine for now. |
You should be able to override the theme locally. But this particular PR is doing that, by specifying an explicit way of formatting vs. just the semantic markup, and letting the theme do the formatting. I think the better change here would have been for the theme to apply the underlining for mutable vars. e.g. using this in settings.json until the themes do the same:
|
Thanks @woody77 ! This works for me and deactivates underlines:
|
@woody77 I was trying to follow the guidance from VSCode, where they say if you introduce a semantic token, you should provide a fallback textmate scope: |
I agree it should be a fallback scope, but one that doesn't imply formatting, and instead is a more structural (maybe keyword.control.rust?) |
This PR builds on #4397 to enhance the existing syntax coloring.
Underline mutable variables
The textmate scope
markup.underline
underlines identifiers, which is a nice way to make mutable vars stand out:Italicize static variables
The textmate scope
markup.italic
italicizes identifiers. Italic = static is a common convention in IDEs like IntelliJ: