-
Notifications
You must be signed in to change notification settings - Fork 17.4k
Color variable.language differently from other variables #18383
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just picked one at random
That's what I usually do too. 😂 Sometimes I look where the same color is already used. In this case it would be the same as support.class
and a few more. Maybe ok, since they don't clash?
Move this to base so it applies to every language and not just javascript
👍 Yeah, that might be a good idea. Especially since variable.language
isn't in use already, it wouldn't break anything. In general, I think we should try to move to _base
as much as possible and only tweak it on a per language basis if it doesn't fit. Then other language packages can start to use it too.
I'm a little worried that this particular color choice (the yellow-ish one) will be too big of a change for right now. After releasing 1.32, we've gotten a lot of feedback that people find color changes really disruptive. Currently, normal variables are just the base text color: light gray in one-light-syntax, and black in one-dark-syntax. I think I'd be more comfortable with the change if we were to make these "special language variables" a subtle variation of that color. So on It may be too disruptive to introduce a whole new color though. |
Another option would be to make |
Overall, when making color choices, I'd like to start thinking it something like this:
And so on. Coming from TextMate, we didn't always have clear enough information to follow such a framework, but now we do. Does that way of thinking about it make sense? |
@maxbrunsfeld Thanks for the review 💯 I understand your vision a lot more now. This will help me out a lot when making tree-sitter scope changes 👍 Maybe we should document this somewhere 💭 @simurai Thanks for the review 🙇 I added a commit to address both points of review feedback:
In this commit I removed coloring red for any I chatted with @maxbrunsfeld on slack to suggest holding off on merging the language-javascript PR until this is reviewed and approved. Because we can't ship one fix without the other. Making it |
This change as it proposed now is gonna require some thorough test plan and verification process to go over all languages and how they scope Some prerequsite changes to better support this PR: The latest commit scopes |
A guide would be great. When it comes to syntax highlighting, 2 parts are very clear:
But then there is this 3rd aspect: What scope should have what color? Or how do the scopes relate to each other? And here it's where things get very hand-wavy. Currently it's defined in the themes, but I think to really be able to decide, you need to understand, use and care about a language. Not sure if all theme authors do (me included 😇 ). Some options that might reduce the "randomness":
Option 2 + 3 are probably not possible without breaking a lot? Anyways, back to this PR. 😄
I replaced function a() {
foo.aw // default @mono-1
window.aw // variable.support @mono-2
this.aw // variable.language @mono-2 + bold
}
Using bold, is something the One themes don't really do, but maybe ok to start using bold more.
Hmm.. that feels a bit too drastic. In Less it would be:
People might say: "Why are the variables not colored anymore?". |
Yeah. You're right it's gonna break textmate grammars and not make much difference to tree-sitter. We should definitely revert that change. It would also break keyword arguments that we restored color to in Atom 1.32.1 by adding the
Yeah I think these would break a lot of things. Having a guide/convention both for scopes that grammars should apply and how they should be colored in relation to each other would be nice to have. Scopes seem to be kinda standard for every core grammar, maybe it's because that's how they get colored or maybe there is some convention already that I don't know about. But there are some differences. For example php has a whole lot of red with one-dark because it decided to scope local variables as In the WIP pr to add a tree-sitter php grammar I have currently removed this local variable scope but I am considering adding it back as with a different class that is not colored by one-syntax.
I don't mind if you want to change it. I just added bold because that was what was suggested 🙂 |
@sadick254 This can be closed, it's no longer relevant now that #20524 is merged. It would be good to also merge atom/language-javascript#690 to fully support reserved variables like |
Issue or RFC Endorsed by Atom's Maintainers
N/A
Description of the Change
Both textmate and tree-sitter scopes language variables (
this
,super
,arguments
) asvariable.language
in JavaScript (After atom/language-javascript#620 is merged). These should be colored differently from other variables.Looks like this:
Alternate Designs
base
so it applies to every language and not just javascript where we have the onlyvariable.language
with tree-sitter after Add more scopes to the tree-sitter grammar language-javascript#620 is merged. It's possible we will add morevariable.language
to other languages shortly and they already exist in textmate.Possible Drawbacks
People that disabled tree-sitter likes the red color:
Verification Process
I checked that
this
is colored differently with tree-sitter enabled and atom/language-javascript#620 mergedRelease Notes
/cc: @maxbrunsfeld @simurai