jeff-hykin / experimental-tree-sitter

💾 The hub for getting a VS Code Tree Sitter working
MIT License
18 stars 0 forks source link

Not backwards compatible with existing themes #2

Open jeff-hykin opened 5 years ago

jeff-hykin commented 5 years ago

1. We need access to the current theme

Theme's normally set colors with textmate scopes, and sadly none of the built in VS Code ThemeColor-terms are designed to be used for text/code (its exclusively textmate). Even worse than that, as far as I know, since this is only an extension we don't actually have access to the textmate scopes that are being set by the current theme. See https://github.com/microsoft/vscode/issues/32813#issuecomment-488572556 However, we can access the theme by simply finding the .json file the theme is stored in, which is what other extensions are doing see: https://github.com/microsoft/vscode/issues/32813#issuecomment-495005152

2. We need a system for themes to select parts of the code

See https://github.com/jeff-hykin/experimental-tree-sitter/issues/4

3. We need a translation from TextMate scopes to Tree Sitter scopes

There's many TextMate scopes, however many of them follow patterns and there are a non-trival number of cross-language scopes. There is some opportunity for automation, by finding which Tree Sitter scopes overlap 95-100% with particular TextMate scopes, however there will still need to be many hand-picked mappings from TM scopes to Tree Sitter scopes.

Then we can auto-convert to achieve backwards compatibility for any theme

Once all of the major TextMate scopes have been mapped (a large but not impossible task), a function can be created that can take an old theme as input and produces a tree-sitter theme as output. This can be done on at runtime, without the theme maker needing to do anything and can be cached for efficiency. This is the goal since backwards compatibility is probably the largest roadblock to VS Code integrating the Tree Sitter.