From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Noah Peart Newsgroups: gmane.emacs.bugs Subject: bug#68054: [PATCH] Add tree-sitter indent rule for lexical decls in js/typescript Date: Wed, 17 Apr 2024 13:21:10 -0700 Message-ID: References: <797AC075-B0C8-4269-B8E3-A1F2C69FA955@gmail.com> <14DD6D3A-B9F5-4E5F-B85B-0A8DF6961723@gmail.com> <5fd5b131-962a-489d-a674-0e199cdfff25@gutov.dev> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="00000000000016c73b0616509977" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8031"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Dmitry Gutov , 68054@debbugs.gnu.org To: Yuan Fu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Apr 17 22:22:17 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rxBnN-0001sq-H1 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 17 Apr 2024 22:22:17 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rxBmx-0000wP-SV; Wed, 17 Apr 2024 16:21:51 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rxBmv-0000vs-KL for bug-gnu-emacs@gnu.org; Wed, 17 Apr 2024 16:21:49 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rxBmv-0003KH-Bh for bug-gnu-emacs@gnu.org; Wed, 17 Apr 2024 16:21:49 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rxBn8-0000bw-Cz for bug-gnu-emacs@gnu.org; Wed, 17 Apr 2024 16:22:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Noah Peart Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 17 Apr 2024 20:22:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68054 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 68054-submit@debbugs.gnu.org id=B68054.17133853032195 (code B ref 68054); Wed, 17 Apr 2024 20:22:02 +0000 Original-Received: (at 68054) by debbugs.gnu.org; 17 Apr 2024 20:21:43 +0000 Original-Received: from localhost ([127.0.0.1]:47935 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rxBmp-0000ZL-2n for submit@debbugs.gnu.org; Wed, 17 Apr 2024 16:21:43 -0400 Original-Received: from mail-oa1-x2a.google.com ([2001:4860:4864:20::2a]:42456) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rxBmn-0000YP-0v for 68054@debbugs.gnu.org; Wed, 17 Apr 2024 16:21:42 -0400 Original-Received: by mail-oa1-x2a.google.com with SMTP id 586e51a60fabf-234f5e54446so87982fac.1 for <68054@debbugs.gnu.org>; Wed, 17 Apr 2024 13:21:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713385282; x=1713990082; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=jPOWWBpnAcTr8YCNf8gjD//np925fIrn8m5Zf4ffsHA=; b=CdMXkL/8AxwdGdk27MW4LLlq5BYsFmmWf7Cyv/RsAkSykx05mhQKpR98pM44dnodp4 pt2e/rsDd+bGcEDtUxjKP+xmnX0AUDFrkxaCIIJSaGB+MpthW4axGZARMYLZp4xuH0mw qJeTmtXG0SBzRKjUgy4XlPxF2rDYswQQMkmzLTpa/ucuWicQcv3QKPaskv/hT8bQGOYG tJV+b/JnGR6OOlRfyD9/Ya6YJL0EmsA5OwE+ItLMaoola9Eg7ifFKmi0p4SliBEi1y+k 4pS/uXo5u6rsqZsiPx8rfzmxRB1DkVB52Ja+Q6nWDt5Wq2VZrtIFHWKa5vyoLqRjddUh dlOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713385282; x=1713990082; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=jPOWWBpnAcTr8YCNf8gjD//np925fIrn8m5Zf4ffsHA=; b=Jb5Yy5jOyfhaZm1QfGn32WW/Lub5iOTL9WwyCSKuJ8r2/fqKP1JnDeVX+ch8WlJJo5 +d9CbbNCqwKGetlTKD7gKqTpz9HHwUZ5eWJb2EZhR2xmium8w3iTicBLcgjmgMBeK2kc 1hL15G0JObNxNtY/ZZZ4Q4D6rf9C6NLyCNBNKjyH6QkDlHfzahzUQgzZSRQX9v8cKGcY vxz+jLgVJNmMuNh8d/KepbB/vfUxuuUXHNLEXYTzw6BvAD2FfZolTFNmQ+AkXxaR+WfS bc26PS9Q6CPuVoxAAXhJx3HsAoYL+tG931BxC91UK4VI1qcF6fDafYb3t83EuNNLhHZf /3BA== X-Forwarded-Encrypted: i=1; AJvYcCXbd6MivNW496+vSIJHFrCi4B3kCAZIMCrz45cX/wwqOAZ8BLUgXkORu58wNUvd++snRU6jVJy5EtDCXC/TGCb7RmIqQO8= X-Gm-Message-State: AOJu0YxAccgL2iFO0KMmki9dwknprGmkD4gJgWr9gABidcTR0Lt68DNy 9hg2L9Zf4sO+GGlfiNb6+Dmkm1Z7c4+jmrOinM0UZfC7LS41qZhjj2i/PuI+O9IQPkLrkg7C1Jk 2x/ZyQMBid8EBSagIisUaNMX1x9w= X-Google-Smtp-Source: AGHT+IE1DgUX6ESpq6Oe045VF+6oCltRWu8akdNMSGgHnLGYl2gpT8Zj7AGU4PiWq1ce3E33KAkoUH95YgZIDjj52+E= X-Received: by 2002:a05:6870:a451:b0:22e:83e8:2f13 with SMTP id n17-20020a056870a45100b0022e83e82f13mr82636oal.24.1713385281857; Wed, 17 Apr 2024 13:21:21 -0700 (PDT) In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:283524 Archived-At: --00000000000016c73b0616509977 Content-Type: multipart/alternative; boundary="00000000000016c73a0616509975" --00000000000016c73a0616509975 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sorry, I forgot about this. I've just added a rule to align the variable_declarators in let, var, and const declarations, but I need some feedback about the indentation for values in the variable_declarators following dangling '=3D'. For example, which of the following would be preferable? 1) indent the dangling values with respect to start of the declaration const a =3D (x: string): string =3D> { return x + x; }, bbb =3D { "x": 0 }, cccc =3D 1, ddddd =3D 0; 2) indent them with respect to the start of the variable_declarator const a =3D (x: string): string =3D> { return x + x; }, bbb =3D { "x": 0 }, cccc =3D 1, ddddd =3D 0; 3) align with the variable declarators (this is the same as js-mode) const a =3D (x: string): string =3D> { return x + x; }, bbb =3D { "x": 0 }, cccc =3D 1, ddddd =3D 0; I've attached a patch with with the rules for the 3 options here. On Sun, Dec 31, 2023 at 8:56=E2=80=AFPM Yuan Fu wrote: > > > > On Dec 31, 2023, at 5:41 AM, Dmitry Gutov wrote: > > > > On 31/12/2023 07:35, Noah Peart wrote: > >> Yea, I agree that would be better - would you align on start the > variable names, or '=3D' like > >> `c-lineup-assignments`? > > > > Like js-mode would be good. > > > > I'm not familiar with c-lineup-assignments, but we could add different > variations later. > > Also, if you are feeling adventurous, I noticed that the second variable > in a lexical_declaration isn=E2=80=99t fontified in variable-name-face. I= t=E2=80=99d be > nice to fix that as well. > > Yuan --00000000000016c73a0616509975 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Sorry, I forgot about this. I've just added a rule to = align the variable_declarators
in let, var, and const declarations, but= I need some feedback about the indentation
for values in the var= iable_declarators following dangling '=3D'.

For example, which of the following would be preferable?

1) indent the dangling values with respect to start of the declarat= ion

=C2=A0 =C2=A0 const a =3D
=C2=A0 =C2=A0 =C2=A0 =C2=A0 = (x: string): string =3D> {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = return x + x;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 },
=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 bbb =3D
=C2=A0 =C2=A0 =C2=A0 =C2=A0 {
=C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 "x": 0
=C2=A0 =C2=A0 =C2=A0 =C2=A0 },=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 cccc =3D
=C2=A0 =C2=A0 =C2=A0 =C2=A0= 1,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ddddd =3D 0;
=C2=A0=C2=A0
<= /div>
2) indent them with respect to the start of the variable_declarat= or

=C2=A0 =C2=A0 const a =3D
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (x: string): string =3D> {
=C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return x + x;
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 },
=C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 bbb =3D
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "x= ": 0
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 },
=C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 cccc =3D
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 1,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ddddd =3D 0;

3) align with the variable declarators (t= his is the same as js-mode)

=C2=A0 =C2=A0 const a = =3D
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (x: string): string =3D> {
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return x + x;
=C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 },
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 bbb = =3D
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 "x": 0
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= },
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 cccc =3D
=C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 1,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ddddd =3D 0;

I've attached a patch with with the rules for the= 3 options here.

On Sun, Dec 31, 2023 at 8:56=E2=80=AFPM Yuan Fu <<= a href=3D"mailto:casouri@gmail.com">casouri@gmail.com> wrote:


> On Dec 31, 2023, at 5:41 AM, Dmitry Gutov <dmitry@gutov.dev> wrote:
>
> On 31/12/2023 07:35, Noah Peart wrote:
>> Yea, I agree that would be better - would you align on start the v= ariable names, or '=3D' like
>> `c-lineup-assignments`?
>
> Like js-mode would be good.
>
> I'm not familiar with c-lineup-assignments, but we could add diffe= rent variations later.

Also, if you are feeling adventurous, I noticed that the second variable in= a lexical_declaration isn=E2=80=99t fontified in variable-name-face. It=E2= =80=99d be nice to fix that as well.

Yuan
--00000000000016c73a0616509975-- --00000000000016c73b0616509977 Content-Type: text/x-patch; charset="US-ASCII"; name="typescript-ts-decl-indent.patch" Content-Disposition: attachment; filename="typescript-ts-decl-indent.patch" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_lv49byd80 ZGlmZiAtLWdpdCBhL2xpc3AvcHJvZ21vZGVzL3R5cGVzY3JpcHQtdHMtbW9kZS5lbCBiL2xpc3Av cHJvZ21vZGVzL3R5cGVzY3JpcHQtdHMtbW9kZS5lbAppbmRleCBhYjFkNzZhYjIwZS4uOWRiZTVk ZjgzNjggMTAwNjQ0Ci0tLSBhL2xpc3AvcHJvZ21vZGVzL3R5cGVzY3JpcHQtdHMtbW9kZS5lbAor KysgYi9saXNwL3Byb2dtb2Rlcy90eXBlc2NyaXB0LXRzLW1vZGUuZWwKQEAgLTkxLDYgKzkxLDE2 IEBAIHRzeC10cy1tb2RlLS1pbmRlbnQtY29tcGF0aWJpbGl0eS1iODkzNDI2CiAgICAgIGAoKCht YXRjaCAiPCIgImpzeF90ZXh0IikgcGFyZW50IDApCiAgICAgICAgKChwYXJlbnQtaXMgImpzeF90 ZXh0IikgcGFyZW50IHR5cGVzY3JpcHQtdHMtbW9kZS1pbmRlbnQtb2Zmc2V0KSkpKSkKIAorKGRl ZnVuIHR5cGVzY3JpcHQtdHMtbW9kZS0tYW5jaG9yLWRlY2wgKF9uIHBhcmVudCAmcmVzdCBfKQor ICAiUmV0dXJuIHRoZSBwb3NpdGlvbiBhZnRlciB0aGUgZ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