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, 27 Dec 2023 01:21:05 -0500 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="0000000000006e83f3060d77ceae" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="6416"; mail-complaints-to="usenet@ciao.gmane.io" To: 68054@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Dec 27 07:22:33 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 1rINJI-0001Qw-PI for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 27 Dec 2023 07:22:32 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rINIr-00023K-OO; Wed, 27 Dec 2023 01:22:05 -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 1rINIq-000236-C3 for bug-gnu-emacs@gnu.org; Wed, 27 Dec 2023 01:22:04 -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 1rINIq-0004LF-4H for bug-gnu-emacs@gnu.org; Wed, 27 Dec 2023 01:22:04 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rINIo-00057S-47 for bug-gnu-emacs@gnu.org; Wed, 27 Dec 2023 01:22:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Noah Peart Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 27 Dec 2023 06:22:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 68054 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.170365808719629 (code B ref -1); Wed, 27 Dec 2023 06:22:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 27 Dec 2023 06:21:27 +0000 Original-Received: from localhost ([127.0.0.1]:35241 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rINIE-00056W-Kd for submit@debbugs.gnu.org; Wed, 27 Dec 2023 01:21:27 -0500 Original-Received: from lists.gnu.org ([2001:470:142::17]:34100) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rINIB-00056J-MK for submit@debbugs.gnu.org; Wed, 27 Dec 2023 01:21:24 -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 1rINI7-0001zu-KF for bug-gnu-emacs@gnu.org; Wed, 27 Dec 2023 01:21:19 -0500 Original-Received: from mail-ot1-x333.google.com ([2607:f8b0:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rINI5-0004Dv-Py for bug-gnu-emacs@gnu.org; Wed, 27 Dec 2023 01:21:19 -0500 Original-Received: by mail-ot1-x333.google.com with SMTP id 46e09a7af769-6dc076e9e59so23325a34.2 for ; Tue, 26 Dec 2023 22:21:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703658076; x=1704262876; darn=gnu.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=sRQH7sWBz8h9Q04GA8N+t3NrMfPcYvRSehORSuwRlZQ=; b=eutM4p63uMooQp02GF56O6XdvqbT3wyyF9Fj3vaeDl7nr+Uum0Jx1/oxQdYexyjy2o XZB3kOc4i6UtvvGTEk7VnhN5g+yqwMNMIKGPYpjL0oqEi2QJNn2Rqq04fd/cZJp0/HdE 8ZSkHCvV6POKEBK29/DiFt2fGyu4GkG42lpmjUdObcN4rLjAtB1ikxiIf9OMWPzHBYc6 1R99CrJnb4RfikU0yll+kZQ38HFoFvobj2h5dab2yGW9TISrSnaqUL7jkp1B+gCA3UN1 AkI97TAo2YUjgskiLuFjFwg7Xo3MIiXH4d/SXEULdcezfkNR1vKwtrphOCIe9K3JZouF zMGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703658076; x=1704262876; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=sRQH7sWBz8h9Q04GA8N+t3NrMfPcYvRSehORSuwRlZQ=; b=SoCJgW3FYX4UUDZzFje7UdzbXZSrivbssqsJBFNnsINhSGJBa+uMfQdP5YYniwD3sL ruMWG16arU4wSQ9FJMnHUqg/yTQw10sTway/WLDZJl+gnh6SLuM9vre8yBnuSWPHdnLc Tm/JcBfQmpSVXiv2OOBB3HBxcldTN+XioyENR5/KM21SNYq+k+GEdo0d+bWJxLePde7L 5xXjWnWDloSpH/Akq2RSxZfiqgYk0aZGhEZnDz5b0nTbUVbvudlejX5ng8m9EE0mHM6S oapdgCGaqh5/kV7LgUi0LHP4cueOGOlzZa5WxMHvARBzzfG7zMWDLL3yc3Las7yUe5I9 OtKw== X-Gm-Message-State: AOJu0YwIFK33wSQ10yU/D89f/znKFnd/CmIPbxR3/jC6YqhHSHyvSlYS /NtwGko8lhR35UW8kvalYeBrqOAmcxXmmblQ+t/GetsO+FrCeTNe X-Google-Smtp-Source: AGHT+IEozu9CYXucLu+tzRf6aHj0N9oH++5eM5h+VT8lTjUYSkk/KOtFiRuo4ugtlsjyqQzOZ+jsnPhtnnIeImYIm5o= X-Received: by 2002:a05:6870:9720:b0:1fa:fd62:18f5 with SMTP id n32-20020a056870972000b001fafd6218f5mr10420660oaq.22.1703658075832; Tue, 26 Dec 2023 22:21:15 -0800 (PST) Received-SPF: pass client-ip=2607:f8b0:4864:20::333; envelope-from=noah.v.peart@gmail.com; helo=mail-ot1-x333.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action 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:276930 Archived-At: --0000000000006e83f3060d77ceae Content-Type: multipart/alternative; boundary="0000000000006e83f1060d77ceac" --0000000000006e83f1060d77ceac Content-Type: text/plain; charset="UTF-8" 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. In GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.33, cairo version 1.16.0) of 2023-12-26 built on nverno-XPS-8940 Repository revision: d376462c7183752bf44b9bd20bf5020fe7eaf75a Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.12101004 System Description: Ubuntu 22.04.3 LTS Configured using: 'configure --prefix=/usr/local --with-modules --with-tree-sitter --with-threads --with-x-toolkit=gtk3 --with-xwidgets --with-gnutls --with-json --with-mailutils --with-jpeg --with-png --with-rsvg --with-tiff --with-xml2 --with-xpm --with-imagemagick CC=gcc-12 CXX=gcc-12' --0000000000006e83f1060d77ceac Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Tags: patch

* Bug: `js-ts-mode` and `typescript-ts-= mode` are missing indentation
rules for lexical declarations that span m= ultiple lines.

Recipe to reproduce:

Using the following funct= ion to configure js-ts-mode and indent the
buffer:

=C2=A0 =C2=A0 = (defun try-indent ()
=C2=A0 =C2=A0 =C2=A0 (interactive)
=C2=A0 =C2=A0= =C2=A0 (js-ts-mode)
=C2=A0 =C2=A0 =C2=A0 (setq-local indent-tabs-mode n= il)
=C2=A0 =C2=A0 =C2=A0 (setq-local js-indent-level 4)
=C2=A0 =C2=A0= =C2=A0 (indent-region (point-min) (point-max)))

Add the following e= xample to a buffer and call `try-indent`.

=C2=A0 =C2=A0 let foo =3D = 1,
=C2=A0 =C2=A0 bar =3D 2; // no indent rule matches this line

N= o indentation is applied to the second line.

This patch adds a simpl= e indentation rules for `js-ts-mode` and
`typescript-ts-mode` to handle = the multi-line lexical declarations.


In GNU Emacs 30.0.50 (build= 1, x86_64-pc-linux-gnu, GTK+ Version
3.24.33, cairo version 1.16.0) of = 2023-12-26 built on nverno-XPS-8940
Repository revision: d376462c7183752= bf44b9bd20bf5020fe7eaf75a
Repository branch: master
Windowing system = distributor 'The X.Org Foundation', version 11.0.12101004
System= Description: Ubuntu 22.04.3 LTS

Configured using:
=C2=A0'con= figure --prefix=3D/usr/local --with-modules --with-tree-sitter
--with-th= reads --with-x-toolkit=3Dgtk3 --with-xwidgets --with-gnutls
--with-json = --with-mailutils --with-jpeg --with-png --with-rsvg
--with-tiff --with-x= ml2 --with-xpm --with-imagemagick CC=3Dgcc-12
CXX=3Dgcc-12'
--0000000000006e83f1060d77ceac-- --0000000000006e83f3060d77ceae Content-Type: text/x-patch; charset="US-ASCII"; name="js-ts-indent-decls.patch" Content-Disposition: attachment; filename="js-ts-indent-decls.patch" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_lqndzgao0 RnJvbSA0YzI3OTNmY2RiMTE5OTI1MzM5NjUxMWExM2MxMzUxOWM3NmJiODE3IE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBOb2FoIFBlYXJ0IDxub2FoLnYucGVhcnRAZ21haWwuY29tPgpE YXRlOiBXZWQsIDI3IERlYyAyMDIzIDAwOjUwOjQ2IC0wNTAwClN1YmplY3Q6IFtQQVRDSF0gQWRk IHRyZWUtc2l0dGVyIGluZGVudCBydWxlIGZvciBsZXhpY2FsIGRlY2xzIGluCiBqcy90eXBlc2Ny aXB0CgoqIGxpc3AvcHJvZ21vZGVzL3R5cGVzY3JpcHQtdHMtbW9kZS5lbAoodHlwZXNjcmlwdC10 cy1tb2RlLS1pbmRlbnQtcnVsZXMpOiBBZGQgaW5kZW50IHJ1bGUgZm9yCmxleGljYWxfZGVjbGFy YXRpb25zLgoKKiBsaXNwL3Byb2dtb2Rlcy9qcy5lbCAoanMtLXRyZWVzaXQtaW5kZW50LXJ1bGVz KTogQWRkIGluZGVudCBydWxlCmZ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