Closed neaumusic closed 6 years ago
I agree with you that object keys are technically unquoted strings and I would love to change that, the sublime core devs even tried to that exactly that in the past but it broke many color schemes and so they had to revert the change: https://github.com/sublimehq/Packages/issues/141#issuecomment-182826789
I would be inclined to add this as a configurable option, soon I'll have to use a build system to simplify the syntaxes and that will allow me to make the syntaxes configurable.
For now, to make the keys looking like a string, a key need to be added to the color scheme, in your example:
<dict>
<key>name</key>
<string>Object literal key</string>
<key>scope</key>
<string>meta.object-literal.key, meta.object-literal.key variable.other.readwrite</string>
<dict>
<key>foreground</key>
<string>#e6db74</string>
</dict>
</dict>
I was getting a weird error "Expected element key" when trying to add that snippet to the Monokai.tmTheme file, but I ended up adding those scopes in the String entry and it works great
<dict>
<key>name</key>
<string>String</string>
<key>scope</key>
<string>string, meta.object-literal.key, meta.object-literal.key variable.other.readwrite</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#E6DB74</string>
</dict>
</dict>
https://github.com/borela/naomi/releases/tag/v3.7.0 Reverted object keys to unquoted strings except for numbers. I let the relevant portion of code commented only so that when I implement the build system this feature could be disabled if users so desire.
In your case, you probably won't need to patch the color scheme anymore.
The latest patch was published and now the syntax will adopt babel sublime's behavior highlighting object literal keys.
If someone want to revert this change (I mean revert to the default property name color, I mean white or whathever) :
Sublime Text 3/Packages/User/Monokai.sublime-color-scheme
:
{
"rules": [
{
"scope": "source.js meta.declaration.variable.js.fjsx15 meta.object-literal.js.fjsx15 meta.block.js.fjsx15 meta.object-literal.key.js.fjsx15 string.unquoted.js.fjsx15",
"foreground": "var(white)"
},
]
}
(To get scope name, use developper tool "Show scope name")
Similar to Babel plugin, Object keys should be strings or numbers!!
Desired (Babel) syntax highlight:
Current (Naomi) syntax highlight: