How does the highlighter know that I'm inside quotes and how can I use it in my plugin?

The highlighter does a good job at recognizing symetrical delimiter like quotes.
For a plugin I’m making I would like to know if I’m inside quotes or not, which is not an easy task. Take for example:

"Don't" + 'miss'`

(Suppose my cursor i on the t)
What function the highlighter use and that I can reuse to know that I’m inside "Don't" and no t" + ?

as a small hack you can check for spaces. E.g. this is very rare: " text ", so if we see quote and space afterwards it’s most likely closing one and we’re inside string. This is not really reliable, but paired with some other checks Matt work well.

Kakoune parses buffer from beginning, so when highlighter sees first quote it colors it as string. There’s no magic here. But I don’t think that your plugin should do whole parsing, as it will be slow.

So can I grab some value somewhere that can tell me that I’m inside quotes ?
If the highlighter know that it inside quotes, I should be able to know it too right ?

If highlighter exposes this info, then yes. But I don’t know if it does. Better ask @mawww

@scr you may be interested in this GH issue :