-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
I'm currently trying to inject some syntax into string literals by the use of the injectTo
grammar feature. The idea is that I match on some specifically formed strings to provide custom syntax highlighting for specific strings in macros (mitsuhiko/insta#149).
Configuration wise my extension does something like this:
"grammars": [
{
"language": "insta-snapshots",
"scopeName": "source.insta-snapshots",
"path": "./syntaxes/insta-snapshots.tmLanguage.json"
},
{
"scopeName": "source.inline-insta-snapshots",
"injectTo": [
"source.rust"
],
"path": "./syntaxes/inline-insta-snapshots.tmLanguage.json",
"embeddedLanguages": {
"meta.embedded.inline-insta-snapshot": "insta-snapshots"
}
}
]
Then in the grammar I'm matching on something. This all works and eventually I end up injecting a custom sub syntax into strings that look like @r"""..."""
. The issue here now is that once RLS runs a "string" semantic token is put over the entire region which I just parsed which completely removes my custom syntax again.
I was looking into how this is supposed to be solved or how other languages are doing it but the only thing I found is that apparently rust analyzer is the only language server which emits semantic string tokens? At least I do not see similar things in typescript and some other languages I tried.
Not sure if filing this here makes any sense but considering there are many things working together I figured I start filing something here.
The following screenshot shows the issue:
The token under the cursor is correctly determined to be keyword.insta
but the styling in the theme is discarded because of the string
semantic token which takes precedence.