This definitely feels like something that should be solved with meta
scopes. Honestly, tooling shouldn’t be relying at all (IMO) on the “main” scopes because those can get funged by clear_scopes
, overlapping embedded scopes (e.g. when embedding within another language), and even just changes to the mode definition.
The problem of course is that meta
scopes aren’t anywhere near universally applied right now, and where they are applied, it’s somewhat inconsistent.
On the subject of clear_scopes
though… It is my opinion that clear_scopes: true
is an anti-pattern and should be avoided whenever possible. What that declaration basically says is “take a nuclear hammer to all the carefully-curated stuff that I don’t control”. I much prefer the more targeted clear_scopes: 1
(or similar integer), so that the scopes you’re removing are locally-controlled and you don’t accidentally remove something more important from your distant parent contexts (e.g. a function body meta scope).