emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can this indentation be achieved with treesit-simple-indent-rules?


From: Yuan Fu
Subject: Re: Can this indentation be achieved with treesit-simple-indent-rules?
Date: Mon, 19 Jun 2023 23:12:21 -0700


> On Jun 19, 2023, at 12:11 PM, Nicolás Ojeda Bär <n.oje.bar@gmail.com> wrote:
> 
> Hello,
> 
> I am trying my hand at writing a tree-sitter major mode. I am using
> "treesit-simple-indent-rules" for indentation, but have not managed to
> get the indentation style that I am looking for.
> 
> Suppose that the AST that you are trying to indent is (a (b c)) and
> that you have
> the indentation rules
> 
>    ((parent-is "a") parent-bol 2)
>    ((parent-is "b") parent-bol 0)
> 
> Then the following is well-indented:
> 
> a
>  b
>  c
> 
> However, if "b" is in the same line as "a", then the result of indentation is:
> 
> a b
> c
> 
> But I would like to have instead
> 
> a b
>  c
> 
> That is, I would like "c" to be indented _as if_ "b" was on a separate
> line. Is there a way to achieve this?

There are different approaches to this. Could you maybe explain why you want to 
indent it like this, so that I know what’s your intent? Maybe also give a 
concert example? I’m guessing something like a is special and you only want one 
level of indentation for the whole statement, even if it occupies multiple 
lines; or it could be that b and c are special and should align?

Yuan


reply via email to

[Prev in Thread] Current Thread [Next in Thread]