bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#60602: 29.0.60; treesit-simple-indent doesn't work for top-level nod


From: Dmitry Gutov
Subject: bug#60602: 29.0.60; treesit-simple-indent doesn't work for top-level nodes
Date: Fri, 6 Jan 2023 16:55:07 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2

On 06/01/2023 15:40, Piotr Trojanek wrote:
Note that other tree-sitter modes have similar indentation rules, e.g.
ruby-ts-mode.el:

    ;; Slam all top level nodes to the left margin
    ((parent-is "program") parent 0)

and same for typescript-ts-mode.el:

   ((parent-is "program") parent-bol 0)

Probably relatedly, in ruby-ts-mode (and probably others), when the first child of a block node (e.g. sequence statements) is reindended, it's often that its parent is passed to the rules, not that actual child. Which makes the indentation rules irregular, forcing us to add extra cases.

Note this comment at ruby-ts-mode:635:

           ;; well as statements.  Note that the first statement of a
           ;; body_statement hits the node as "body_statement" and not
           ;; as the assignment, etc.

and the rules below.

Not sure if there is an easy fix for this, however, given that both body_statement and its first child start at the same position. Perhaps a translation step before the rules are applied? E.g. in case of Ruby body_statement or block_body we would translate to the first child node first, to then apply the rules to it. Same for 'program', I guess.





reply via email to

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