Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

js: nested template highlighting #1670

Open
aeosynth opened this issue Nov 5, 2017 · 2 comments
Open

js: nested template highlighting #1670

aeosynth opened this issue Nov 5, 2017 · 2 comments

Comments

@aeosynth
Copy link

aeosynth commented Nov 5, 2017

javascript template literals can have more template literals embedded within them. kak does not highlight nested templates correctly:

`string ${`also a string: let x = 42`}`

js

@danr
Copy link
Contributor

danr commented Jan 7, 2018

I am not sure if this is possible to express given the way nested highlighters
are specified in Kakoune today. The problem is that the region highlighter's line

   literal       "`"  (?<!\\)(\\\\)*`         '' \

will exit the literal at the first backtick even if it is nested inside a ${...}:

`string ${`also a string: let x = 42`}`
^ start   ^ end

I don't see any way to tell the region highlighter to understand nestings of ${...}.

@mawww
Copy link
Owner

mawww commented Jan 9, 2018

Yeah, I dont think we can parse such nested syntax with the existing infrastructure, we would need more complex region definitions, where regions can contain subregions and those subregions might have the same delimiters as their parent region...

This would be quite a change in the region highlighter design, but it might make sense to do it at some point. I must admit I am not entirely satisfied with the way we define regions at the moment, it would be nice to have each region defined by its own add-higlighter command adding that region definition inside the region highlighter instead of hardcoding all regions in a single command.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants