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: Wed, 24 Apr 2024 03:15:08 +0300 Message-ID: <661fc11d-6da8-4fe5-a900-80ed1b41823a@gutov.dev> 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> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38944"; 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 Wed Apr 24 02:16:06 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 1rzQIv-0009wN-Jx for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 24 Apr 2024 02:16:06 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzQIh-0000aQ-2v; Tue, 23 Apr 2024 20:15: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 1rzQIf-0000aH-ND for bug-gnu-emacs@gnu.org; Tue, 23 Apr 2024 20:15: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 1rzQIf-0005Er-Bc for bug-gnu-emacs@gnu.org; Tue, 23 Apr 2024 20:15:49 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rzQIv-0005Ar-5l for bug-gnu-emacs@gnu.org; Tue, 23 Apr 2024 20:16:05 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 24 Apr 2024 00:16:05 +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.171391773919595 (code B ref 68054); Wed, 24 Apr 2024 00:16:05 +0000 Original-Received: (at 68054) by debbugs.gnu.org; 24 Apr 2024 00:15:39 +0000 Original-Received: from localhost ([127.0.0.1]:55151 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rzQIU-00055z-QS for submit@debbugs.gnu.org; Tue, 23 Apr 2024 20:15:39 -0400 Original-Received: from fout1-smtp.messagingengine.com ([103.168.172.144]:41277) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rzQIQ-00054G-By for 68054@debbugs.gnu.org; Tue, 23 Apr 2024 20:15:37 -0400 Original-Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailfout.nyi.internal (Postfix) with ESMTP id 000BC138011A; Tue, 23 Apr 2024 20:15:11 -0400 (EDT) Original-Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Tue, 23 Apr 2024 20:15:11 -0400 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=1713917711; x=1714004111; bh=2DhB3gForYNnQzOJSNNGKX13hWOjiRICHI+PjAcZ/gY=; b= Li7WdwKx3lbsHqmKUKElgab3SLxweHx6deQ87qle99fRu8RxzSzn586O97i+bO0X ECp8Wt5LrZFJ/6tZGA23/U6FwzHABNgT8pvekniwUM36Elwb6qoQwAp45r3UNhpr iKX6no/hcmE9qf3ghnjBuDLf5js81bBwSQXlEstY6TxeMZ7IJh6/J7f7g2He9l1q aesb04P/AWRdwpoBzGAbpAHGSpaFM+8Jh0iY71xiG7JQzq4+rdZLOSTUvqyXsJuH laqdjLeur+3v7esMuT2CX2GqNVbbcjM0oOg+ovMWQDgIP6ZMG3ivOLMtNxih/qQU wsdJrdhaAE35P0t+DioRKw== 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=fm3; t=1713917711; x= 1714004111; bh=2DhB3gForYNnQzOJSNNGKX13hWOjiRICHI+PjAcZ/gY=; b=F bM5feBGS6OvLkaYG9ft9ll2qtmHz6gyDktp86fCSXEXqkYuDwPfYLBEgQ7gj4vKa YstsBMN9YfnwGxu4Ve7WcJ0puQacm5cRShgCM8+HiKpXXfC5AwXpaT1RpXEEAHJy FnBelvqJt/zx17AQeuTDUXFUIdxSXGOnz7nNU0xDSHYcgh5QA638Se2kPqrOXaxK tx4bURhV395s6uLKgmzVA7xLMwNasqTnhu6RYGKrGgdq5NCOtS7Nl564SmPDQESD J5nTePJSaHHYA7vVIHP4tnern7lG5hwWMyCcEwMo0xkXaXW7nOZ9rJuBqpNnxnVL M+3lfkegG9Tlio9yPlC0A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudelvddgfeefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepkfffgggfuffvvehfhfgjtgfgsehtkeertddtvdejnecuhfhrohhmpeffmhhi thhrhicuifhuthhovhcuoegumhhithhrhiesghhuthhovhdruggvvheqnecuggftrfgrth htvghrnhepgeelfeetkefghfdvhfdtgeevveevteetgeetveegtedthefhudekteehffeu keeknecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepug hmihhtrhihsehguhhtohhvrdguvghv X-ME-Proxy: Feedback-ID: i0e71465a:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 23 Apr 2024 20:15:10 -0400 (EDT) Content-Language: en-US In-Reply-To: <49231C5D-E89E-4AA3-AB02-51340994EA20@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:283898 Archived-At: On 23/04/2024 08:07, Yuan Fu wrote: >> 1) indent the dangling values with respect to start of the declaration >> >> const a = >> (x: string): string => { >> return x + x; >> }, >> bbb = >> { >> "x": 0 >> }, >> cccc = >> 1, >> ddddd = 0; >> >> 2) indent them with respect to the start of the variable_declarator >> >> const a = >> (x: string): string => { >> return x + x; >> }, >> bbb = >> { >> "x": 0 >> }, >> cccc = >> 1, >> ddddd = 0; >> >> 3) align with the variable declarators (this is the same as js-mode) >> >> const a = >> (x: string): string => { >> return x + x; >> }, >> bbb = >> { >> "x": 0 >> }, >> cccc = >> 1, >> ddddd = 0; >> >> I've attached a patch with with the rules for the 3 options here. > I don’t really know what’s the convention, if there is one. Maybe Dmitry has better idea. Personally I like option 1. 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). This seems like a rare enough case, so it probably doesn't matter too much, so I'd suggest picking one style and implementing it, and then adjusting based on user feedback later.