emacs-devel
[Top][All Lists]
Advanced

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

Re: More Tree Sitter Questions / Problems.


From: Dmitry Gutov
Subject: Re: More Tree Sitter Questions / Problems.
Date: Mon, 26 Dec 2022 18:24:27 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2

Hi Perry,

On 14/12/2022 22:43, Perry Smith wrote:
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

First of all, this is IMO not too terrible, as it shows the user how the code is parsed, which can be helpful on different occasions.

And as apparent from practice, people who don't like this behavior (e.g. Rubocop frowns on it) will just break the line after "=". Seems like the different indentation behaviors across different editors (when the team uses several ones) converge on this practice anyway.

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).

As luck would have it, I'm finishing work on a feature request for ruby-mode for a user option which switches indentation from this sort of AST-aware to simpler continuations. See the latest patch in debbugs#60186.

Further, have you looked into supporting/being more-or-less compatible with existing indentation-related options in ruby-mode? At least those that affect SMIE.

It should be helpful to synchronize, both to provide a straightforward upgrade path for existing users, and to ensure good experience for those who don't build tree-sitter yet, and for users of older Emacs.



reply via email to

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