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: Thu, 25 Apr 2024 15:48:37 -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> <49231C5D-E89E-4AA3-AB02-51340994EA20@gmail.com> <661fc11d-6da8-4fe5-a900-80ed1b41823a@gutov.dev> <3cf27c4d-d5ee-423c-a0d2-cfae297d36ae@gutov.dev> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="0000000000001a9e610616f397d9" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37816"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Yuan Fu , 68054@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Apr 26 00:50:20 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 1s07v2-0009e0-DM for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 26 Apr 2024 00:50:20 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s07ug-0002pX-Dy; Thu, 25 Apr 2024 18:49:59 -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 1s07ua-0002pM-RW for bug-gnu-emacs@gnu.org; Thu, 25 Apr 2024 18:49:53 -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 1s07ua-0004Qt-Ba for bug-gnu-emacs@gnu.org; Thu, 25 Apr 2024 18:49:52 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1s07ur-0006eC-I9 for bug-gnu-emacs@gnu.org; Thu, 25 Apr 2024 18:50:09 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Noah Peart Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 25 Apr 2024 22:50:08 +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.171408537325169 (code B ref 68054); Thu, 25 Apr 2024 22:50:08 +0000 Original-Received: (at 68054) by debbugs.gnu.org; 25 Apr 2024 22:49:33 +0000 Original-Received: from localhost ([127.0.0.1]:33458 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s07u8-0006Wa-I3 for submit@debbugs.gnu.org; Thu, 25 Apr 2024 18:49:31 -0400 Original-Received: from mail-oa1-x2c.google.com ([2001:4860:4864:20::2c]:51347) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s07ty-0006Tp-B9 for 68054@debbugs.gnu.org; Thu, 25 Apr 2024 18:49:20 -0400 Original-Received: by mail-oa1-x2c.google.com with SMTP id 586e51a60fabf-2351c03438cso648029fac.2 for <68054@debbugs.gnu.org>; Thu, 25 Apr 2024 15:48:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714085329; x=1714690129; 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=Cbcap2Of2dGk93QKztO4Hf/0rBd96kXJE1D9lODFmzM=; b=X4QuY9ONV0NgHpvoHC3NqG2u7SCyxCI+HMSW2L1nTDhHN/pEjREsHkDsC1Qu83xwqB Zf/yhwU3waXxePfpx4T74sy9GLVL5CQdV2WbEFhbobSeZfcD8J2+jHV/BgMv/Vziz+3F 5A4xZNV5ICPxsg3qXJC4rxfuaSMrPRa3PB2+zPNuKv/aUZtZyAQx0a1B24OkUiHFx9YL banxm6XIendBJSWqM2cVpXgY7awIa4PTOfl0wnmqJSle2BZLxbJmH7+Jub+INFg0yrjW utLkbeb/83vFzikIpRJnoysmajtrz2N8p8wTKbnSOxQTq6YVoj0Sp7XQ031Y1fbAilMP 51vQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714085329; x=1714690129; 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=Cbcap2Of2dGk93QKztO4Hf/0rBd96kXJE1D9lODFmzM=; b=YWaVt9S0PUiqFa5w3+AZjHl8z00/98lSqdKboYwSZCAwJSGN+KHGgYzC3BTZz8LmE/ 2R57dCBVWOPwPW8XFagEUOoR07IeQdHeg9rWvGdJ0eqNMzPc5w3DOH5+ikhf6G8fyfKd YgkHqySBE6FoRyeLLQK5m3/ZP2RGqwxu7k0Vu4YnluHdyM1Wq11k7tvNOAo7sq2RO4rO M/dxHx3Bb9IVgrJR+69Jnh0yd+2jQh5grq4raAR8lTcpKegETdw/cWpxX9g6sFx8S2hc WNp66RuCarD0vGtQPrR9D6D22t09Ubl+r5dH4AiS9KPNir3emLS5N91tdnQgd7/Ma4It a3Mg== X-Forwarded-Encrypted: i=1; AJvYcCUKH0XuLkrcscpMZUc7+iUcI7JynjhezlXWtNSXTOdB/05OPrOEa0mjnr3UHwjdK5o1BuVkpobDfmaNgNzJPHxuVr3zaTQ= X-Gm-Message-State: AOJu0YxXkeR4Ny771gdiUlNYPDpdnANOX2RCLHlxHVeuNz0O2CJgrWNf E8EKegIhkCeJ1lGH53l4fDKb0fIq/HqKz4zWG75QNcpcIAL/f5LAFFmN4AnjwlCwBRxIeii4paK Mboh6qT7PKQyEm+J+A7zZGCiwBAcdNaZ5FK0= X-Google-Smtp-Source: AGHT+IE/8u4uXGnWn0rGEaj6nzFfUH/l9NzMfFHR6yiLb8D38zve1myM/w8z5/Ir5WSqU2qBDv/3i6M4aJdVdejom80= X-Received: by 2002:a05:6870:d38d:b0:238:dcff:90c9 with SMTP id k13-20020a056870d38d00b00238dcff90c9mr961605oag.10.1714085328229; Thu, 25 Apr 2024 15:48:48 -0700 (PDT) In-Reply-To: <3cf27c4d-d5ee-423c-a0d2-cfae297d36ae@gutov.dev> 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:283960 Archived-At: --0000000000001a9e610616f397d9 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Ok, I can make a patch for option 3 (the same as js-mode) instead. It's implementation is the simplest also. Would that work? Thanks On Wed, Apr 24, 2024 at 4:15=E2=80=AFPM Dmitry Gutov wro= te: > On 24/04/2024 05:36, Noah Peart wrote: > > > What js-mode does (looks like 3) shouldn't be too bad, but I wouldn'= t > > mind an extra indentation level for such cases, too (example 2). > > > > The problem I found with option 2/3 was cases like the following (which > > also seem like the most common) where I expect the start of > > the function be indented according to `typescript-ts-mode-indent-offset= `, > > not with the declaration keyword "const" as in `js-mode` (and option 3)= . > > > > const someFuncWithReallyLongName =3D > > async (x: number, y: number, z: number): Promise =3D> { > > // ... > > }; > > I don't know, in my understanding the line break after the "=3D" (or its > absence) is usually a good enough look to choose between indentation > offsets for a given statement. I.e. with the break after =3D it would be > indented deeply, and without it (keeping "async" on the first line) the > body would have the same base indentation as the "const" statement. > > Though of course some users like it differently anyway. > --0000000000001a9e610616f397d9 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Ok, I can make a patch for option 3 (the same as js-mode) = instead. It's
implementation is the simplest also.=C2=A0 Would that= work?

Thanks=C2=A0

On Wed, Apr 24= , 2024 at 4:15=E2=80=AFPM Dmitry Gutov <dmitry@gutov.dev> wrote:
On 24/04/2024 05:36, Noah Peart wrote:
>=C2=A0 > What js-mode does (looks like 3) shouldn't be too bad, = but I wouldn't
> mind an extra indentation level for such cases, too (example 2).
>
> The problem I found with option 2/3 was cases like the following (whic= h
> also seem like the most common) where I expect the start of
> the function be indented according to `typescript-ts-mode-indent-offse= t`,
> not with the declaration keyword "const" as in `js-mode` (an= d option 3).
>
>=C2=A0 =C2=A0 =C2=A0 const someFuncWithReallyLongName =3D
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 async (x: number, y: number, z: number): Pr= omise<void> =3D> {
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 // ...
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 };

I don't know, in my understanding the line break after the "=3D&qu= ot; (or its
absence) is usually a good enough look to choose between indentation
offsets for a given statement. I.e. with the break after =3D it would be indented deeply, and without it (keeping "async" on the first lin= e) the
body would have the same base indentation as the "const" statemen= t.

Though of course some users like it differently anyway.
--0000000000001a9e610616f397d9--