emacs-devel
[Top][All Lists]
Advanced

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

More Tree Sitter Questions / Problems.


From: Perry Smith
Subject: More Tree Sitter Questions / Problems.
Date: Wed, 14 Dec 2022 14:43:09 -0600

All three of ruby-mode, java-mode, and c-mode indent a simple arithmetic _expression_ broken into lines like this:

foodog = 12 + 4 *
    18 * 99 + 8

I think this is the Java sample which has the indent set to 4.  I’ll call this “the old way”.

All three of ruby-ts-mode, java-ts-mode, and c-ts-mode indent it like this:

variable = 12 + 4 *
                18 * 99 + 8

In Ruby’s case, this rule is doing it:

           ((parent-is "binary") first-sibling 0)

If I comment that rule out, then no rule hits and so there is no indent (the line is left unchanged no matter how it is indented).

While I think the new way is ultra cool… I am 100% positive I am in the vast minority on this topic.  Most prefer to have it indented the old way.

I’ve developed two new rules but I believe these will not solve the issue 100%:

           ((ancestor-is "parenthesized_statements") (ancestor "parenthesized_statements") 1)
           ((ancestor-is "assignment") (ancestor "assignment") ruby-ts-mode-indent-offset)

I also wrote ancestor-is and ancestor so now I get:

eddie = (a + b *
         c * d + 12)
bobby = a + b *
  c * d + 12

I fear as I test and play with this more I’m going to need more rules to catch all the cases where a line starts with a term of an arithmetic _expression_.

Perry

Attachment: signature.asc
Description: Message signed with OpenPGP


reply via email to

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