Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[YAML] Everything is "String" colored now #3288

Closed
keldin-coding opened this issue Mar 23, 2022 · 20 comments
Closed

[YAML] Everything is "String" colored now #3288

keldin-coding opened this issue Mar 23, 2022 · 20 comments

Comments

@keldin-coding
Copy link

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 keldin-coding added the T: bug A bug in an existing language feature label Mar 23, 2022
@keldin-coding
Copy link
Author

#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 😅

@deathaxe
Copy link
Collaborator

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

@keldin-coding
Copy link
Author

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

@deathaxe
Copy link
Collaborator

See sublimehq/sublime_text#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 deathaxe added question and removed T: bug A bug in an existing language feature labels Mar 23, 2022
@deathaxe
Copy link
Collaborator

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

@keldin-coding
Copy link
Author

keldin-coding commented Mar 23, 2022

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
Copy link
Author

Thanks for the help and confirmation! :)

@rgpublic
Copy link

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.

@levonet
Copy link

levonet commented Nov 10, 2022

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.

@deathaxe
Copy link
Collaborator

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.

@levonet
Copy link

levonet commented Nov 10, 2022

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

@deathaxe
Copy link
Collaborator

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.

@h0jeZvgoxFepBQ2C
Copy link

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

@h0jeZvgoxFepBQ2C
Copy link

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
Copy link

h0jeZvgoxFepBQ2C commented Nov 11, 2022

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

@jfcherng
Copy link
Collaborator

jfcherng commented Nov 11, 2022

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.

@h0jeZvgoxFepBQ2C
Copy link

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

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

@pasqualguerrero
Copy link

pasqualguerrero commented Nov 11, 2022

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>

@geerlingguy
Copy link

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

@deathaxe
Copy link
Collaborator

Updates requests for default color schemes are still pending (sublimehq/sublime_text#3590).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants