Packages
Packages copied to clipboard
[YAML] Everything is "String" colored now
What happened?
As of updating to the latest sublimeText, it seems like even keys of Hashes/Dictionaries are now highlighted as if they were regular strings. Before, they used to be differentiated (pink vs green in my specific color scheme) making it easier to identify key/value pairings. I would guess this is related to #3272, but I can't be sure as I've never dug through the syntax highlighting code before.
https://github.com/sublimehq/Packages/pull/2564
It may actually be related to this and require a similar update to Packages/Agila Theme/Agila Oceanic Next.tmTheme" which is the color scheme I use 😅
This scope naming change has been made by intent to get inline with how JSON keys are scoped for years now.
And coming back to this now, even the built-in Monokai didn't get updated. Well enough, I think I can customise the UI, was just surprising all of a sudden
See https://github.com/sublimehq/sublime_text/issues/3590 for built-in color schemes, which has lasted for years as well.
The point is, what you see in YAML is "state of the art" in JSON for years.
There's also the following statement about it: https://discord.com/channels/280102180189634562/280102180189634562/956253218034315304
Fair enough. I'll leave the same fix here as is in the issue I linked in case someone stumbles on this rather than those and is in the discord which worked for Monokai:
{
"name": "Mapping Key Names",
"scope": "meta.mapping.key string",
"foreground": "var(red2)"
}
Thanks for the help and confirmation! :)
For anyone wondering where to apply the fix mentioned by @lirossarvet:
Just call Preferences => Customize Color Scheme
and add this between the square brackets under "rules":
{
"name": "Mapping Key Names",
"scope": "meta.mapping.key string",
"foreground": "#ff79c6"
}
This will color everything like it used to be. Really weird change, by the way. Clearly a regression if you ask me. The syntax highlighting is almost useless without this. I thought it was broken before I found this issue.
I copied the YAML.sublime-package from the previous version. This temporarily solved the problem. But I would like this problem to be solved with the next version of ST.
It's your color scheme, which needs to be tweaked. Syntax definition won't be reverted.
YAML applies the same scopes to keys as JSON has done for ages. Everyone how complains about how YAML looks should have noticed it for JSON long before.
@deathaxe
YAML applies the same scopes to keys as JSON has done for ages. Everyone how complains about how YAML looks should have noticed it for JSON long before.
There is a significant difference between JSON and YAML. The first format was created with love for machines and hate for people. The second is the opposite.
This is true but absolutely unrelated. Both represent structured key-value pairs. YAML is even a super-set of JSON.
As such, both now use the same scopes for keys and values. The main difference is JSON only supporting keys to be quoted strings while they can be of any data type (or even expressions/macros) in YAML.
The point is: JSON already looking pretty plain without any color scheme tweaks. So fixing color scheme rules for YAML fixes JSON or vice versa as scoping is now consistent accross the two.
Yeah this really looks like a bug, came here to find a solution for the broken syntax highlighting.
Could someone tell me where to add this fix, I don't have a "Customize Colorscheme" option?
Also this broken appearance just happened yesterday for me with update to the new Sublime release, not before?
Could someone tell me where to add this fix, I don't have a "Customize Colorscheme" option?
from the command palette
Also this broken appearance just happened yesterday for me with update to the new Sublime release, not before?
It first happened on Mar 24, 2022 as you can see in this thread. However, that's a dev build. If you use a stable build, it happens yesterday.
Ah I see thanks, I'm using following for the railscasts theme:
{
"name": "Mapping Key Names",
"scope": "meta.mapping.key string",
"foreground": "#FFC66D"
}
Ah I see thanks, I'm using following for the railscasts theme:
{ "name": "Mapping Key Names", "scope": "meta.mapping.key string", "foreground": "#FFC66D" }
If you want you can directly edit your *.tmTheme to not have config in separated files:
<dict>
<key>name</key>
<string>Mapping Key Names</string>
<key>scope</key>
<string>meta.mapping.key.yaml string</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#FFC66D</string>
</dict>
</dict>
It's a bit confusing since all the built-in color schemes seem to have 'broken' (even if they're not 'broken', YAML is incredibly hard to parse now, where it was not before, at least using Cobalt and testing on a couple other built-in color schemes).
Updates requests for default color schemes are still pending (https://github.com/sublimehq/sublime_text/issues/3590).