Currently the scope guidelines recommends that functions be scoped with meta.function
including its contents, so a function inside a function would have the meta.function
appearing twice.
Looking at the core syntaxes, array literals as scoped with meta.sequence
which is also applied to the contents. The problem with these scopes is that you can’t highlight the punctuation without affecting the contents, while I was able to make it work with very convoluted rules, at the end I just concluded that we either need specific scopes or a way to select them sequentially.
Being able to give different colors to punctuation is a very important feature to languages like Javascript where the meaning of a [] and {} changes drastically depending on the context. So I am proposing that we add specific meta scopes to punctuations:
meta.class.punctuation
meta.class.body.punctuation
meta.function.punctuation
meta.function.parameters.punctuation
meta.function.body.punctuation
meta.block.punctuation
meta.sequence.punctuation
meta.object-literal.punctuation
There’s no meta.property-access
(the bracket in: a[]
) or meta.destructuring
in the core packages but I am already including them here to debate.
meta.property-access.punctuation
meta.destructuring.punctuation
These scopes would appear only at the punctuation. This solution would be simpler than adding a new feature to the color scheme engine and it would be compatible with other editors’ color schemes.