Replies: 1 comment
-
That pattern is already in JavaScript's default pattern list. (TypeScript reuses that.) When multiple patterns match, multiple faces are applied. You can try putting the cursor inside the string template and evaluating If you use In general, patterns whose internals may be highlighted should be placed towards the end, so that they have low priority. I don't use JavaScript/TypeScript much, so I haven't reviewed their highlighting patterns extensively. I would gladly accept a PR that rearranges the patterns to better follow that principle.
It's possible, but I haven't thought through that functionality yet. I don't think this specific case needs it, though.
Recursion would help with situations like template-in-template. Making the priority correct by shuffling the patterns should be sufficient in this case. |
Beta Was this translation helpful? Give feedback.
-
Hi. I started looking into tree-sitter today, hoping I could find a way to get string interpolation syntax highlighting working for typescript.
Looking at some of the examples, I put the following code in my config:
This successfully highlights the
${
and}
. But everything in between is the same face. Is there a way, for the_
item, instead of suppling a face, maybe supply a function?I know the tree finds every node when I view it in the debug function. So it should be able to theoretically also highlight everything it finds.
At this point, how would we go over whatever is in between and add the appropriate highlighting? I would think it would be recursive.
Great work on this. It is promising. Thank you.
Beta Was this translation helpful? Give feedback.
All reactions