Sublime Text 4 color scheme rule to control JavaScript unquoted Object literal keys?

150 Views Asked by At

I'm trying out Sublime Text 4 and I'm trying to customize the Monokai color-scheme for Javascript files. So far I've been able to do everything but change the color of unquoted Object keys from white to yellow. Quoted keys are yellow, but unquoted are still white. Does anyone know of a rule scope that would work for this?

For Example:

{
    foo: 'bar', // foo is white
    'baz': 'bang' // baz is yellow
}

I'm trying to make foo be yellow. I've found solutions that work with sublime text 3, but nothing for sublime text 4

1

There are 1 best solutions below

1
On BEST ANSWER

Seems to work just fine for me.

This is how it looks like as you have said (with your snippet in the Monokai scheme)

enter image description here

If you go to the UI: Customize Color Scheme from the command palette, you can add a rule to your user version of Monokai.

 {
       "scope": "meta.mapping.key.js",
       "foreground": "var(yellow)",
 }

After which, you get the desired coloring.

enter image description here

How did I know what scope to use ? Just place the cursor before foo and go to View -> Developers -> Show Scope Name from the main menu or press ctrl + alt + shift + p to see the scope names.