catppuccin / sublime-text

🍋 Soothing pastel color schemes for Sublime Text
MIT License
112 stars 13 forks source link

YAML not working very well? #11

Closed avesst closed 5 months ago

avesst commented 1 year ago

Tried installing this on Sublime Text 4. It does not handle YAML very well: image

MatthiasPortzel commented 7 months ago

https://github.com/sublimehq/sublime_text/issues/3590 has an example of what rule needs to be added for this.

avesst commented 7 months ago

Ah so this is a Sublime Text issue. Closing.

MatthiasPortzel commented 7 months ago

I don't think it's a Sublime Text issue—it's an issue with Sublime Text's default color schemes, that Catppuccin also suffers from. I'll take a stab at it. (Edit: not right now but at some point if I remember.)

MatthiasPortzel commented 7 months ago

I'm not sure what the best path forward is so I'm going to post a bunch of screenshots and ask in the Catppuccin Discord for thoughts. Ideally we don't want to mess up JS that much, so I've got JS as a control on the right, next to JSON and YAML. The scopes that Sublime applies are totally different from VSCode. The weird part in my opinion is that in JSON and YAML, there's a "string" scope applied after (with more specificity) than the meta.mapping.key scope, so you have to target it explicitly or it gets highlighted as a string.

This is Sublime right now:

Screenshot 2024-03-03 at 7 12 50 PM

This is VSCode right now:

Screenshot 2024-03-03 at 7 16 14 PM

Option 1:

Screenshot 2024-03-03 at 9 30 49 PM

Option 2:

option2

I prefer Option 1, because it's more consistent and more semantic when programming. It makes keys everywhere blue. Option 2 kind of highlights the quoted keys in YAML and JSON, which some people might like.

Code block for both options ```json // Option 1: { "name": "awdawd", "scope": "meta.mapping.key string, meta.mapping.key", "foreground": "var(blue)" }, { "scope": "meta.mapping.key punctuation.definition.string.begin, meta.mapping.key punctuation.definition.string.end", "foreground": "var(overlay2)" }, // Option 2: { "name": "awdawd", "scope": "meta.mapping.key, meta.mapping.key.json string, meta.mapping.key string.unquoted", "foreground": "var(blue)" }, { "scope": "meta.mapping.key punctuation.definition.string.begin.json, meta.mapping.key punctuation.definition.string.end.json", "foreground": "var(overlay2)" } ```
sgoudham commented 6 months ago

Hey @MatthiasPortzel, sorry meant to reply officially to this.

I believe @ghostx31 and I agree that Option 2 would be the way forward here as it seems to match VSCode the most under the various files. Little bit odd that "key" is always blue in JSON files but that seems to be a limitation across both options so not much we can do.

ghostx31 commented 6 months ago

Yep Option 2 is much better since we have to try to be as close as possible to VSCode.

Sublime's texmate engine has some limitations so there's nothing that we can do about it so it's cool to match VSCode as much as we can.

MatthiasPortzel commented 6 months ago

We can also match VSCode exactly. There are no Sublime limitations here. (The limitations in Sublime's engine come up in edge cases like JS arrow function definitions that have been split over multiple lines. And Sublime's engine, although backward-compatible with TextMate's, has become a lot more sophisticated.)

The difference between Sublime and VSCode is just how things are scoped. VSCode applies different scopes and scope precedences to things than Sublime does. So VSCode's coloring is natural in VSCode-land by just coloring "keys" as blue, and VSCode doesn't scope keys in JS objects as keys. Sublime does scope keys in JS objects as keys and so if we want them to not be colored, we need an extra rule to re-color keys in JS as text.

I can put up a PR today to match VSCode and we can see what it looks like.