Giter VIP home page Giter VIP logo

Comments (2)

Thom1729 avatar Thom1729 commented on June 9, 2024 1

I dug into this, and the Monokai rule is:

{
    "name": "Tag name",
    "scope": "entity.name.tag | meta.mapping.key string.unquoted",
    "foreground": "var(red2)"
},

So the current version of Monokai is deliberately targeting things like JS object keys and highlighting them red. I checked the last ST3 release and the rule is different:

{
    "name": "Tag name",
    "scope": "entity.name.tag",
    "foreground": "var(red2)"
},

So this is a deliberate change in the core Monokai syntax, not a regression in babel-sublime. Granted, it is a visible change in behavior for babel-sublime/Monokai users.

It would be possible to restore the yellow color by removing the meta.mapping.key scope. This would have to be done by modifying JS Custom's string_object_keys extension. From the look of it, it would be a fairly intrusive change because the meta.mapping.key scope is applied at a higher level.

On the other hand, there's an easy workaround: if you use Monokai, and you prefer the old highlighting, then you can customize Monokai with an added rule:

{
    "name": "JS object bare key",
    "scope": "meta.mapping.key string.unquoted.js",
    "foreground": "var(yellow)"
},

The babel-sublime v10 rewrite went out of its way to preserve the original highlighting of bare keys a) to make the v9–v10 transition more seamless for users, b) to reduce the number of highlighting changes to make regressions more visible, and c) because the string.unquoted scope is arguably more correct than the core syntax's scoping. The string_object_keys extension is small and unintrusive, so it wasn't a big deal to add.

On the other hand, this change a) is due to a change in Monokai and is not a regression in babel-sublime, b) would have happened in v9 anyway, c) would be fairly intrusive to change, and d) might make highlighting worse in non-Monokai color schemes. In addition, Sublime Text 4 makes it easy to tweak color schemes and even offers a built-in command for doing so (“UI: Customize Color Scheme”).

Therefore, I'm not inclined to change babel-sublime to restore the yellow highlighting under Monokai, and at some point I should update the example images in the readme to reflect the current version of Monokai. But I'm available if anyone needs help tweaking their color scheme.

from babel-sublime.

fontesrp avatar fontesrp commented on June 9, 2024

Thanks for looking into this @Thom1729!

For the reference of anyone else that decides to use the workaround, here are the steps I followed:

  1. Create the file ~/Library/Application Support/Sublime Text/Packages/User/Monokai.sublime-color-scheme
  2. Add the following contents:
{
  "rules": [
    {
      "foreground": "var(yellow)",
      "name": "JS object bare key",
      "scope": "meta.mapping.key string.unquoted.js"
    }
  ]
}

from babel-sublime.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.