There are a number of scopes missing from the tree-sitter grammar that are present in its TM-style sibling. Many of these aren't used by one-dark-syntax or other common syntax themes, which is probably why they've been overlooked. Here's what I've added:
All strings, regardless of type, were scoped simply as string. I fleshed out these scope names to match the TM-style grammar: string.quoted.single, string.quoted.double.interpolated, et cetera.
Global variables had no scope name. Now they're scoped as variable.other.readwrite.global.
Operators weren't scoped at all. Now they're all given keyword.operator scope names equivalent to what they get in the TM-style grammar.
Ordinary method parameters were scoped as variable.parameter, but method parameters with default values got no scope. Fixed this oversight.
A number of punctuation scopes were added, including single- and double-quotes around strings, as well as the . and &. operators.
The atom-light-syntax theme is the first builtin theme I found that actually shows these differences. The existing grammar is on the left, and the updated grammar is on the right:
Alternate Designs
One thing worth mentioning: the distinguishing quotation marks via :nth-child selectors seems brittle. I'd love it if an :nth-last-child selector were available, but I've seen the code that implements :nth-child and I'm not sure I understand it well enough to try yet.
Benefits
Better syntax highlighting and richer contextual information for commands.
Possible Drawbacks
Hard to think of any. If this were a bold new direction for scope naming, perhaps there'd be some, but this is just about parity with the old grammar. The changes aren't even visible in most of the common syntax themes; the ones that are visible are obviously improved in consistency.
Description of the Change
There are a number of scopes missing from the tree-sitter grammar that are present in its TM-style sibling. Many of these aren't used by
one-dark-syntax
or other common syntax themes, which is probably why they've been overlooked. Here's what I've added:string
. I fleshed out these scope names to match the TM-style grammar:string.quoted.single
,string.quoted.double.interpolated
, et cetera.variable.other.readwrite.global
.keyword.operator
scope names equivalent to what they get in the TM-style grammar.variable.parameter
, but method parameters with default values got no scope. Fixed this oversight.punctuation
scopes were added, including single- and double-quotes around strings, as well as the.
and&.
operators.The
atom-light-syntax
theme is the first builtin theme I found that actually shows these differences. The existing grammar is on the left, and the updated grammar is on the right:Alternate Designs
One thing worth mentioning: the distinguishing quotation marks via
:nth-child
selectors seems brittle. I'd love it if an:nth-last-child
selector were available, but I've seen the code that implements:nth-child
and I'm not sure I understand it well enough to try yet.Benefits
Better syntax highlighting and richer contextual information for commands.
Possible Drawbacks
Hard to think of any. If this were a bold new direction for scope naming, perhaps there'd be some, but this is just about parity with the old grammar. The changes aren't even visible in most of the common syntax themes; the ones that are visible are obviously improved in consistency.
Applicable Issues
Can't find any among the open issues.