Closed nefrob closed 4 months ago
Checking out how Python 3.12 f-strings are handled might be useful here. I think this is the grammar file: https://github.com/microsoft/vscode/blob/e4595ad3998a436bbf68d32a6c59e9d49fc63e32/extensions/python/syntaxes/MagicPython.tmLanguage.json#L3772.
Another things being looked into is clearing the highlighting, allowing for escaped blocks in strings to have their highlighting reset: https://stackoverflow.com/questions/77848154/how-to-clear-textmate-grammar-highlighting-for-variables-in-strings/78597228?noredirect=1#comment138581704_78597228.
Trying the initial suggestion was unsuccessful:
Closing this as I'm not sure there is a great way to do this via regexes (one of the limitations of textmate grammars). We will continue to improve the grammar over time to try and get the most we can out of textmate.
Hmm maybe using \G
would help with nesting. I'll look into this in some follow up improvements.
Ex. like make
which follows some similar syntax to just
: https://github.com/textmate/make.tmbundle/blob/master/Syntaxes/Makefile.plist#L396C12-L396C17.
Escaped blocks, i.e.
{{ ... }}
should highlight as plain just syntax rather than string color (current behavior).For example,
var
should be plaintext in the following scenarios:And string colored in this following scenario:
Just does not support tested escaped blocks, but it does support nested strings within an escaped block. For instance, in this scenario the string in the escaped block is separate from the outer string:
i.e.
string(escape(string(var)))
rather thanstring({{) var string(}})
.Performing regex matching to properly highlight this will be a little tricky.
Couple this with needing to ignore escaped blocks within nested strings:
and ways you can avoid creating an escaped block, ex.
we have a lot to solve for without much flexibility to check the current "scope" (i.e. within a string or within an escaped block) in a Textmate grammar.
Any suggestions here are appreciated. This isn't a high priority issue to solve for me so I'll put in time on this here and there.