|
From: | Dmitry Gutov |
Subject: | Re: Can this indentation be achieved with treesit-simple-indent-rules? |
Date: | Tue, 20 Jun 2023 19:59:09 +0300 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 |
On 20/06/2023 19:16, Nicolás Ojeda Bär wrote:
Thanks for the suggestion. That would work in the "abstract" example because "a" is of width 1, but would not work in general. You can see it clearly if we use "aaa", "bbb" and "ccc" instead of "a", "b", "c": starting from the correctly indented aaa bbb ccc if we put "bbb" in the same line as "aaa" we will get (using parent instead of parent-bol) aaa bbb ccc but would like to get aaa bbb ccc
Sounds like this could work, then: ((parent-is "a") parent-bol 2) ((parent-is "b") grand-parent 2)If "a" might also reside not at indentation (with some tokens before it), you'll need to decide which indentation to have for that case. Maybe the above will be fine, or maybe you could use the 'standalone-parent' anchor instead.
See treesit-simple-indent-presets for the full list of predefined ones. And if none fit exactly, you can define a custom function with the same signature (or several) which can do more advanced calculations, lookarounds, etc.
[Prev in Thread] | Current Thread | [Next in Thread] |