zargony / atom-language-rust

Rust language support in Atom - LOOKING FOR MAINTAINER, see #144
MIT License
116 stars 33 forks source link

Lifetime labels aren't tokenized properly #90

Open adrian5 opened 7 years ago

adrian5 commented 7 years ago

I don't know if this is fixable, but lifetime labels like 'static appear to end up in an element category that isn't targeted by syntax themes.

Below the information Atom gives me on such elements (not sure if that helps):

Inherited from span.storage.modifier.lifetime.rust
atom-text-editor::shadow .storage.modifier.lifetime.rust, atom-text-editor::shadow .entity.name.lifetime.rust {
    color: #48fafd;
}
adrian5 commented 7 years ago

In case I wasn't clear enough, the following screenshot shows a mis-colored element: highlight_issue I get cyan lifetimes regardless of the syntax theme used, and suspect it to be some fallback or ui-theme defined color. If lifetimes took on a color of the theme's palette, that would be nice. If other users do not experience this problem, then please speak up.

zargony commented 7 years ago

Lifetimes are recognized into scope storage.modifier.lifetime.rust (whole lifetime including apostrophe) and entity.name.lifetime.rust (only the lifetime's name). This allows syntax themes or your custom css to apply color specifically to lifetime labels. However, I don't know of any syntax theme that does so, so in most cases it will fall back to the more generic storage modifier or entity name color of the syntax scheme. There doesn't seem to be wrong tokenization from the grammar side here.

adrian5 commented 6 years ago

I looked into this again, since no theme implements it and found myself unable to override Atom's styling. It looks like there's a persistent definition that takes precedence over anything themes bring in, probably because the selector is more elaborate:

element-style-overridden

My attempted override is the yellow color style. I think this conflict is what causes every theme to fail applying its own style. Could you give your opinion on this? Is it something that would need to be fixed in the Atom editor repo?

adrian5 commented 6 years ago

Ok, someone pointed me to the reason. You're overriding lifetimes with your own stylesheet in the language package. This creates cyan lifetimes for every theme. Would have been helpful if you had mentioned that in your response. I think you should dial down the default mix from 70% to something betwenn 20% to 10%, since cyan doesn't mesh well with most themes.

zargony commented 6 years ago

Darn, I almost forget about that by myself! Yes, actually, I thought this would be a short-living workaround since there shouldn't be any styles in this package at all. We should find a more suitable permanent solution for this.

adrian5 commented 6 years ago

p.s. Mixing with a color other than @syntax-text-color might be another option. Most themes define it as a low-saturation color which – mixed with cyan – results in saturated cyan. But yeah, try ~20% and see how you like it; I think it's an acceptable quick fix.