-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Latest nightly seems to ignore semantic highlighting settings #6267
Comments
Try |
I've tried that but it has no effect :( As mentioned above, this all worked as expected prior to today (2020-10-17). |
With the new update, I'm having the same problem. I've had |
It's possible that what I'm observing is on account of the new TextMate grammar (49d824a) rather than semantic highlighting being turned on. I don't really know what difference semantic highlighting makes, I just had it turned off because I didn't like having so much of my code colored like functions. |
I would believe this is due to the new textmate grammar if anything as using |
Is there any way I can use vscode's built-in Rust grammar instead of the one that comes with this extension? |
@Veykril When I do that, I don't see any semantic token type listing. So it looks like my editor, at least, doesn't have semantic highlighting enabled. The new grammar just makes it look similar to the way it looks when it is enabled. |
I don't think there is a way to specifically disable/replace a textmate grammar given by an extension unfortunately, I at least don't see/find a way. What exactly is the problem with the new grammar though or rather what is dissatisfying? I use semantic highlighting so I dont know what changed but judging from this Issue here I suppose it's not using the scopes people would expect. |
@Veykril Here's an example of what a couple pieces of the same file look like in my editor: I like some of the changes. A lot of punctuation went from the default color to being colored like The biggest problem for me is that so much stuff is green now!! I'm used to green being used in a few places, mostly for functions, but now it's used for modules (most of the time), enum variants (including Highlighting of attributes has also changed in a way that doesn't make sense to me. And this is probably my most subjective issue, but I liked having different colors for identifiers from the prelude, like There are other things that make the change jarring ( |
That is something the theme decides, not the grammar. The mere task of the grammar is to categorize tokens. It is the theme that decides how it should then look.
Names starting with a capital letter are assumed to be types and thus get |
All I see is what colors the editor chooses, and all of the problems I have seem to be similar in all of the built-in color themes. The only difference is that some themes distinguish between "types" and "functions," causing enum variants to look different depending on what kind of fields they have, which is even worse! I'm sure the new scopes would be very helpful for a theme built specifically for Rust, but I'd rather use the default grammar because of how it looks. |
Enum variants should always start with a capital first letter. (There is a lint for that) This means they should always get the type textmate scope. |
Tuple variants get the function scope. |
Interesting. It seems that the enum rule only matches |
I tried to write an extension to override this (https://marketplace.visualstudio.com/items?itemName=benesch.legacy-rust-syntax) but unfortunately it seems to be impossible to override the textmate grammar that ships with rust-analyzer. At least, I don't know how to do it. I'd like to propose that rust-analyzer not ship a Rust grammar at all, besides the semantic one. That would allow folks to choose the grammar they want by either installing or not installing @dustypomerleau's Rust Syntax extension. Upstream VSCode seems likely to adopt that as the standard Rust grammar, too. (And if they do, then the extension I created should work to undo that.) |
This allows folks to install a different extension to supply the Rust grammar of their choice. Upstream VSCode seems likely to incorporate the grammar that is currently bundled with rust-analzyer as the default grammar anyway. Fix rust-lang#6267.
Whipped that proposal up as a PR here: #6318 |
receives
Old grammar: New grammar: I can do things like extending the meta scope all the way to the closing In any event, I'm flexible on whether to keep it in the repo. I appreciate all the feedback either way. @matklad @bjorn3 @lnicola |
@dustypomerleau as long as you have desire and capacity for fixing the issues as they come up and coordinating with upstream (VS Code) regarding the inclusion of the grammar as the standard one, I think it will be highly beneficial to ship this grammar with rust-analyzer. We are seeing quite a few reports about it, but this is a feature: it's much better to debug grammar while it is in rust-analyzer with a weekly release cycle, than when it is in VS Code. When VS Code ships, it would make sense to remove grammar from rust-analyzer, but not before that. Let me grant you triage rights and r+ on this repo, so that it's easier for you to make grammar changes and fix issues... Done! |
I agree. Letting your grammar bake in Even if it gets merged in Code, we could keep it as a more up-to-date version (if you think it's still possible to improve it further). As for the issue of not being able to override it, IIRC matklad used to have a very bare-bones grammar, so maybe there's still a way? |
Long-term, I think it would be better to ship nothing -- if we ship a grammar, a user can't override it with a custom one. So, sadly, my favorite Rust textmate grammar doesn't work with current ra :) |
I think it's safe to remove the attribution comment 😄. |
If you keep a grammar in the extension, you should probably communicate to users in some way that there's a custom grammar included and no known way to override it. I only came here because I thought what I was seeing was related to semantic highlighting. |
Yeah, unfortunately I just can't use rust-analyzer until this grammar is removed. I know I'm probably weirdly particular, but I can't deal with the new grammar, and no amount of tweaks will change that. Are there any hacks we can use in the meantime to override the grammar? I mean, there must be some sort of extension load order that determines what extension gets to provide the Rust grammar, right? |
@benesch You could fiddle with your |
@benesch there are several options:
|
Could the new grammar be moved to a separate extension so that it can be iterated on independently? |
Yes, it could be moved to a separate extension, but I believe that would be less efficient way to arrive at the worse grammar. |
Thanks for the suggestions. Those are all reasonable, but I'm on the hunt for a solution that allows me to continue to use the latest and greatest rust-analyzer without too much work on my end. So here's the hack that seems to be working for me:
If you're using VSCode Remote like I am, you can tweak the command slightly like so and run it on the remote machine:
That just in-place overwrites the grammar that ships with rust-analyzer with the old grammar that ships with VSCode today. I imagine I'll have to run that command whenever rust-analyzer is auto-updated to a new version, but I can live with that. Also, I'm sorry to be a downer! I'm sure this new grammar is great for most folks, and it's awesome that you've spent so much time improving it, @dustypomerleau. I just have my development environment set up just so and I hate change, I guess. |
For those following along, microsoft/vscode#108254 was just merged. The November edition of VSCode is likely to include the new syntax highlighting. |
Is there anything remaining to do on this issue? @matklad |
I think we can still remove the TextMate grammar (to use the upstream one instead). |
Since rust-analyzer no longer ships a grammar, it's now possible for another extension to supply one! I've released "Legacy Rust Syntax" (https://marketplace.visualstudio.com/items?itemName=benesch.legacy-rust-syntax) for any other weirdos like me who want to stick with the old sort-of broken grammar. It should just work now, if you're on the most recent versions of VSCode and rust-analyzer. |
I have semantic highlight disabled via the configuration below. The latest nightly seems to ignore it now and always applies semantic highlighting. I've also tried to disable it via the global
Editor -> Semantic Highlighting: Enabled
setting.Disabling of semantic highlighting worked as expected prior to
rust-analyzer version: nightly (f0412da)
.EDIT: Per conversation below, the highlighting differences are attributed to a newly introduced grammar.
The text was updated successfully, but these errors were encountered: