Is there a way to know if a line is inside a comment?

I’m working on improving some of my indentation scripts. One of the things I would like to do is make my automatic indentation logic only happen outside of code comments. Is there a way to do this in Kakoune?

In Vimscript, I know it is possible to ask the syntax highlighter what is the syntax category at a given code position.

As far as I know, there’s no way to find the faces that apply to a particular part of the buffer.

I think the existing indentation scripts just assume that they’re in a comment if the line begins with optional-whitespace followed by the comment character.

Thanks. Do you know if any of the indentation scripts take multi-line comments into account?

Hi hugomg, welcome to the community. How about

do what I want.
Check out lenormf’s welcome mat, it’s a great place to start a treasure hunt: kakoune-extra/lineindent.asciidoc. Idea’s a plenty. Hope this helps. Bye :wave:

c-family-indent-on-newline does, in that it will insert * characters inside a block comment, but it’s not the most straightforward piece of kakscript in the world.