GNU bug report logs - #74386
Tree-sitter javascript indentation

Previous Next

Package: emacs;

Reported by: Marius Kjeldahl <marius.kjeldahl <at> gmail.com>

Date: Sat, 16 Nov 2024 23:28:02 UTC

Severity: normal

Full log


View this message in rfc822 format

From: Yuan Fu <casouri <at> gmail.com>
To: Dmitry Gutov <dmitry <at> gutov.dev>
Cc: 74386 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>, Theodor Thornhill <theo <at> thornhill.no>, marius.kjeldahl <at> gmail.com
Subject: bug#74386: Tree-sitter javascript indentation
Date: Thu, 13 Feb 2025 22:27:24 -0800

> On Dec 11, 2024, at 7:20 PM, Dmitry Gutov <dmitry <at> gutov.dev> 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



This bug report was last modified 183 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.