Thom1729 / Sublime-JS-Custom

Customizable JavaScript syntax highlighting for Sublime Text.
MIT License
137 stars 9 forks source link

Object keys have different scope names compared with default JavaScript syntax #89

Closed trongthanh closed 4 years ago

trongthanh commented 4 years ago

I just noticed that in recent release, the scope name of object's keys provided by this plugin is different from ST3's default JavaScript syntax. For example, with below snippet:

const baz = 0;
const obj = {
    baz,
    foo: 'bar', /*1*/
};
const {foo: foo2} = obj; /*2*/

With JS Custom - Default syntax, the scope names of the object key (1) and the renamed key in destructuring (2) are respectively:

  1. source.js.default meta.mapping.js meta.mapping.key.js
  2. source.js.default meta.binding.destructuring.mapping.js meta.mapping.key.js

Meanwhile, with default JavaScript syntax, we've got:

  1. source.js meta.object-literal.js meta.object-literal.key.js
  2. source.js meta.binding.destructuring.mapping.js meta.object-literal.key.js

The reason I noticed and raised this issue is that I have a custom Mariana color scheme that highlight object keys and renamed keys in destructuring (that I posted earlier in another issue #80).

I'd like to know whether this is a bug of JS Custom or it is a feature? If it's intended, any reason behind? Because of this change, my tweak to the theme doesn't work any more with JS Custom but it still work with default JavaScript syntax.

Thom1729 commented 4 years ago

The same change has been merged into the core JavaScript syntax (https://github.com/sublimehq/Packages/pull/2020), but it has not yet been released into a stable build. JS Custom merges upstream changes eagerly.

The change is deliberate; meta.mapping is used across many syntax definitions, whereas meta.object-literal was only used in the JavaScript syntax definition. Going forward, color schemes should target meta.mapping. If you're using a tweaked syntax definition, I'd recommend updating it to support both scopes for the time being.

As it happens, I am also using a tweaked version of Mariana that targets JS object literal keys, and I had exactly the same issue before I remembered that I'd changed the scopes.

trongthanh commented 4 years ago

Understood and sound reasonable. I guess I have to update my custom scheme for this. Thanks for the explanation.