RFC: moving to TextMate style syntax highlighting scopes for KF6
When porting grammars to KSyntaxHighlighting, one of the first things I noticed was the widely different approach to what is usually called scopes and what KSyntaxHighlighting calls "default styles", as well as the abysmally small selection thereof offered and lack of extensibility.
I don't think KSyntaxHighlighting gains anything with its current system being different from what most other cross-editor systems use, as it just makes porting grammars harder and offers less, not more than the TextMate-style scopes system.
Things known to me that use these scopes:
- TextMate grammar files (used by: VSCode, Atom, Sublime Text, TextMate
- TreeSitter highlighting query files (used by: Atom, Helix, has been ported to extensions for lots of editors)
- GitHub linguist (used by: GitHub)
Short explanation of the format:
A TextMate scope looks like this: a.b.c.d
If a grammar gives a scope a.b.c.d
to a region, the highlighter looks for a rule for a.b.c.d
, then a.b.c
, then a.b.
, and finally a
in the theme definition to get styles.
Commonly understood scopes are enumerated here: https://macromates.com/manual/en/language_grammars.
The biggest argument against this I can see is that we've already built everything around dsFoo
styles, and changing that would be a lot of work and break backwards compatibility, hence why I'm proposing this for KF6.