Packages icon indicating copy to clipboard operation
Packages copied to clipboard

[YAML] Everything is "String" colored now

Open keldin-coding opened this issue 3 years ago • 20 comments

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.

Screen Shot 2022-03-23 at 13 41 44

keldin-coding avatar Mar 23 '22 20:03 keldin-coding

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 😅

keldin-coding avatar Mar 23 '22 20:03 keldin-coding

This scope naming change has been made by intent to get inline with how JSON keys are scoped for years now.

deathaxe avatar Mar 23 '22 20:03 deathaxe

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

keldin-coding avatar Mar 23 '22 20:03 keldin-coding

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.

deathaxe avatar Mar 23 '22 20:03 deathaxe

There's also the following statement about it: https://discord.com/channels/280102180189634562/280102180189634562/956253218034315304

deathaxe avatar Mar 23 '22 21:03 deathaxe

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)"
        }

keldin-coding avatar Mar 23 '22 21:03 keldin-coding

Thanks for the help and confirmation! :)

keldin-coding avatar Mar 23 '22 21:03 keldin-coding

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.

rgpublic avatar May 11 '22 13:05 rgpublic

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.

levonet avatar Nov 10 '22 18:11 levonet

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 avatar Nov 10 '22 18:11 deathaxe

@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.

levonet avatar Nov 10 '22 19:11 levonet

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.

deathaxe avatar Nov 10 '22 20:11 deathaxe

Yeah this really looks like a bug, came here to find a solution for the broken syntax highlighting.

h0jeZvgoxFepBQ2C avatar Nov 11 '22 09:11 h0jeZvgoxFepBQ2C

Bildschirmfoto 2022-11-11 um 10 26 09

Could someone tell me where to add this fix, I don't have a "Customize Colorscheme" option?

h0jeZvgoxFepBQ2C avatar Nov 11 '22 09:11 h0jeZvgoxFepBQ2C

Also this broken appearance just happened yesterday for me with update to the new Sublime release, not before?

h0jeZvgoxFepBQ2C avatar Nov 11 '22 09:11 h0jeZvgoxFepBQ2C

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.

jfcherng avatar Nov 11 '22 09:11 jfcherng

Ah I see thanks, I'm using following for the railscasts theme:

    {
      "name": "Mapping Key Names",
      "scope": "meta.mapping.key string",
      "foreground": "#FFC66D"
    }

h0jeZvgoxFepBQ2C avatar Nov 11 '22 09:11 h0jeZvgoxFepBQ2C

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>

pasqualguerrero avatar Nov 11 '22 12:11 pasqualguerrero

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).

geerlingguy avatar Nov 22 '22 18:11 geerlingguy

Updates requests for default color schemes are still pending (https://github.com/sublimehq/sublime_text/issues/3590).

deathaxe avatar Nov 22 '22 18:11 deathaxe