-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
I'm loving the Semantic Highlighting feature, but it makes quite a mess of (macro/derive/etc) attributes. I suspect reliable highlighting within attributes is not feasible, but at least marking all encompassed tokens with the "attribute" modifier would allow users to override the colors of the worst offenders. (e.g. through configuring "*.attribute" : "#XXXXXX" color settings)
An example featuring attributes from the smart-default crate:
This crate allows specifying default values with arbitrary expressions passed via attributes. With Semantic Hightlighting enabled there are numerous problems with the token handling of said expressions. For one, enums/operators/structs/etc are not recognized at all. For other token types, such as number/punctuation, they do not receive the "attribute" modifier, and thus are not contextually-customizable.
Another example from the native-windows-gui crate.
I personally find the random/inconsistent highlighting within attributes to be distracting and unpleasant. If it were possible, on my end I would simply override all attribute token colors with a single value, but without consistent modifier presence it cannot be done.
TL;DR
I would love if rust-analyzer's semantic highlighting feature tagged all tokens enclosed within #[...] or #![...] brackets with the "attribute" modifier.