From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#68054: [PATCH] Add tree-sitter indent rule for lexical decls in js/typescript Date: Sun, 31 Dec 2023 02:31:46 +0200 Message-ID: <5fd5b131-962a-489d-a674-0e199cdfff25@gutov.dev> References: <797AC075-B0C8-4269-B8E3-A1F2C69FA955@gmail.com> <14DD6D3A-B9F5-4E5F-B85B-0A8DF6961723@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8824"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla Thunderbird Cc: 68054@debbugs.gnu.org To: Yuan Fu , Noah Peart Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Dec 31 01:32:20 2023 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 1rJjkZ-00025s-2e for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 31 Dec 2023 01:32:20 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rJjkK-0005YA-2h; Sat, 30 Dec 2023 19:32:04 -0500 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 1rJjkI-0005Xz-NC for bug-gnu-emacs@gnu.org; Sat, 30 Dec 2023 19:32:02 -0500 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 1rJjkI-0006nP-FN for bug-gnu-emacs@gnu.org; Sat, 30 Dec 2023 19:32:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rJjkI-0005Vs-ON for bug-gnu-emacs@gnu.org; Sat, 30 Dec 2023 19:32:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 31 Dec 2023 00:32: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.170398272021184 (code B ref 68054); Sun, 31 Dec 2023 00:32:02 +0000 Original-Received: (at 68054) by debbugs.gnu.org; 31 Dec 2023 00:32:00 +0000 Original-Received: from localhost ([127.0.0.1]:45330 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rJjkG-0005Va-0S for submit@debbugs.gnu.org; Sat, 30 Dec 2023 19:32:00 -0500 Original-Received: from wout4-smtp.messagingengine.com ([64.147.123.20]:53939) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rJjkC-0005VL-Kl for 68054@debbugs.gnu.org; Sat, 30 Dec 2023 19:31:57 -0500 Original-Received: from compute7.internal (compute7.nyi.internal [10.202.2.48]) by mailout.west.internal (Postfix) with ESMTP id 8B5103200063; Sat, 30 Dec 2023 19:31:49 -0500 (EST) Original-Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Sat, 30 Dec 2023 19:31:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gutov.dev; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1703982709; x=1704069109; bh=UZV9Q+4UezXJq37UnojVBKo8Z2Wty56+DPo34hgyN3U=; b= eBWKS++4xqzJRS04jxBJs1AB/iuamkGrG9UYyEQMzjyAemIIEmfo/vfgY0pg/15e qhGf3WscHkma5H3JqqnIW33IkLcLWhcGm/EL/9kQ4Q9WUeoaj5z49rFt/jNoRdj9 3yZOhxkUn6E6p3ObTxQ8G/oY6S22+aKYCdJTI3FIfc9N0TzJItRfNrcIAqM8Cjpr 7xsH7Jyfc32/EMxAiM3EPLHA9OD0u0vMo1w49mYN3ngKEDCbOjY3HAqyVmhZfEkl 72cLgzlv+O/eyrsyocBL+xBjVMPWDrng0Ltlz3Mt4BzlTIz9uZRj7qXSfCahPLG1 JSHr/RBVO7h70ZbtwjGemw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1703982709; x= 1704069109; bh=UZV9Q+4UezXJq37UnojVBKo8Z2Wty56+DPo34hgyN3U=; b=0 CYv+Y0RnvTZXjyi/B1btzy15itmGDRSFu5n+kOadnWKrYVds1c3k5BrTPPSnsBfI l3I3HaSNXOt/NJgNE+nKcQ8D2FmxP5mR7a7X102otem0OqDOP4jpsbExYSjclWvN naPpufqGs5TShef8ry1HBsAhiRCH48cCXw4BLvkYANDnDwmQ4lANhAg7/CMxgnS3 dfi4s/M2v8++QPEk9KSS5d43bXYrL+HAxhsY3e+wZ2uStM/wj+6xWNNJTfOCnfFw HXjtZXiM1nFuQ1KyDXv+G7T18/XNbY9u8rYDMafBd0N0h+tG2tG82whMQrBU0qzU mNIGLO4D3KJNBbc5QeMpQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvdefiedgvdegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepkfffgggfuffvvehfhfgjtgfgsehtjeertddtvdejnecuhfhrohhmpeffmhhi thhrhicuifhuthhovhcuoegumhhithhrhiesghhuthhovhdruggvvheqnecuggftrfgrth htvghrnhepteduleejgeehtefgheegjeekueehvdevieekueeftddvtdevfefhvdevgedu jeehnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepug hmihhtrhihsehguhhtohhvrdguvghv X-ME-Proxy: Feedback-ID: i0e71465a:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 30 Dec 2023 19:31:47 -0500 (EST) Content-Language: en-US In-Reply-To: <14DD6D3A-B9F5-4E5F-B85B-0A8DF6961723@gmail.com> 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:277120 Archived-At: On 30/12/2023 22:31, Yuan Fu wrote: > >> On Dec 29, 2023, at 8:24 PM, Yuan Fu wrote: >> >> >> >>> On Dec 26, 2023, at 10:21 PM, Noah Peart wrote: >>> >>> Tags: patch >>> >>> * Bug: `js-ts-mode` and `typescript-ts-mode` are missing indentation >>> rules for lexical declarations that span multiple lines. >>> >>> Recipe to reproduce: >>> >>> Using the following function to configure js-ts-mode and indent the >>> buffer: >>> >>> (defun try-indent () >>> (interactive) >>> (js-ts-mode) >>> (setq-local indent-tabs-mode nil) >>> (setq-local js-indent-level 4) >>> (indent-region (point-min) (point-max))) >>> >>> Add the following example to a buffer and call `try-indent`. >>> >>> let foo = 1, >>> bar = 2; // no indent rule matches this line >>> >>> No indentation is applied to the second line. >>> >>> This patch adds a simple indentation rules for `js-ts-mode` and >>> `typescript-ts-mode` to handle the multi-line lexical declarations. > It seems that js-mode indents bar to align with foo, rather than indenting one level. I feel that we should do the same, WDYT? Yes, please. This also makes a difference when the variables are declared with 'const' instead of 'let'. We should also support 'var' declarations: the parent node type to match against is "variable_declaration".