Subject: bug#74386: Tree-sitter javascript indentation

From: Yuan Fu <[email-masked]>
Date: Thu, 13 Feb 2025 22:27:24 -0800

> On Dec 11, 2024, at 7:20 PM, Dmitry Gutov <[email-masked]> wrote:
> 
> On 11/12/2024 08:18, Yuan Fu wrote:
>>>> Maybe not by hardcoding this in inside the 'standalone-parent' matcher, but writing this in the indentation rules? Different languages might have differing ASTs for such construct.
>>>> 
>>>> Or if you meant to do a text search, a period might start a method call, but it could also continue a "range" literal in some other language, or some struct initializer (I think?) in C/C++. Also, some languages allow (and style guides suggest) to have the previous at the end of the line, then followed by newline and then the method name.
>>> Not hard-coded, but customizable, like this:
>>> 
>>> Yuan
>>> 
>>> <standalone-predicate-poc.patch>
>> Circling back on this. WDYT? I think this would benefit all “modern” languages with chaining method calls.
> 
> It's an interesting suggestion - and the docstring is very readable.
> 
> I'd be great to see how it works with some existing modes' indentation code - e.g. to try to rewrite any of the rules in ruby-ts-mode (do we have any other ts mode with as many options affecting indentation?).
> 
> OT2H the use of 'standalone-parent' is optional, and it's combined with a matcher anyway, so it's good even if it covers like 80% of the cases.
> 
> What would be our next step in this? Replacing all 'parent-bol' anchors with 'standalone-parent' across most ts modes?

FWIW, I merged the patch for standalone-predicate. I should make a post about c-ts-common-baseline-indent-rules on emacs-devel soon. (Well, maybe later, I’m busy with some tree-sitter bug right now.)

Yuan