From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuan Fu Newsgroups: gmane.emacs.bugs Subject: bug#60025: [PATCH] Add go-ts-mode and go-mod-ts-mode Date: Wed, 14 Dec 2022 11:55:06 -0800 Message-ID: References: <83r0x3pk28.fsf@gnu.org> <83edt2nqgm.fsf@gnu.org> <5HEX4A0JH8fd_VGG1FbzJ8QtBZXlHLKtuAGgc_TUHvzKCzU2Q3PYbbi3rUWeLOBoJzg0qsQgVhwGZCF86A2Xg--I2ep5d1KjKoUoHrxXpqA=@rjt.dev> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27698"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , theo@thornhill.no, 60025@debbugs.gnu.org To: Randy Taylor Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Dec 14 20:56:25 2022 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 1p5Xrc-0006sM-KC for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 14 Dec 2022 20:56:24 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p5XrP-0005fh-LB; Wed, 14 Dec 2022 14:56:11 -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 1p5XrH-0005ep-5T for bug-gnu-emacs@gnu.org; Wed, 14 Dec 2022 14:56:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p5XrG-0000gI-MX for bug-gnu-emacs@gnu.org; Wed, 14 Dec 2022 14:56:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p5XrG-00013x-Dq for bug-gnu-emacs@gnu.org; Wed, 14 Dec 2022 14:56:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Yuan Fu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 14 Dec 2022 19:56:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 60025 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 60025-submit@debbugs.gnu.org id=B60025.16710477184065 (code B ref 60025); Wed, 14 Dec 2022 19:56:02 +0000 Original-Received: (at 60025) by debbugs.gnu.org; 14 Dec 2022 19:55:18 +0000 Original-Received: from localhost ([127.0.0.1]:41252 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p5XqY-00013V-1S for submit@debbugs.gnu.org; Wed, 14 Dec 2022 14:55:18 -0500 Original-Received: from mail-pl1-f180.google.com ([209.85.214.180]:40802) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p5XqW-00013G-21 for 60025@debbugs.gnu.org; Wed, 14 Dec 2022 14:55:16 -0500 Original-Received: by mail-pl1-f180.google.com with SMTP id a9so4481058pld.7 for <60025@debbugs.gnu.org>; Wed, 14 Dec 2022 11:55:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=dVi/DjPWvel832cahgGE+3Mzes7tt36oKJ3U+eiNdYA=; b=Ds+6nQmxCgOPs6Ffv4zqMv0A5Hcq7t7ZAy0fOQ9X2MhjDbK85EZ4Naa0Hmr9ev2jDU 490YfSrk/j4CC34Uc4vIHnSJL03iEZX4TkZqNljoZElqzWXO+aw5rPqo2vBg7Up+bEKJ Z0e2JthRC3F70CNl2sKRuM+KIRcDEnJFTt8JJHx/XdQBNPmnQ4XNt4fNlbVkrzEDxbDm c6DQpd/iX3O4KS7ul2z//EeNIwXWpw0jjeQLwKQmnUIalHWWHSv9ZPhNt+1cdRTnGeyt jfjNde7vyv3os4XmpjiGQlCc1R6ujIRgYqpwYNMUSgpE4Dx0DLFidv4G/YmCfgz3TZ7N wNNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dVi/DjPWvel832cahgGE+3Mzes7tt36oKJ3U+eiNdYA=; b=P/so+4eOiDOHugojdVIl7zs70w7DdQEhATAr+tkUE1CgZ0Sp3XrJfKwK0JesTD5SiO /s0gYCCfG3v+VAbYA3/UiEXcBi7ek74qqemEtm+qTNOL6DLgHuXONtbM5xHi1c/USYSJ bpD7drgCXE1bFXslzFUxg6N+1HTW47f9hYlVUIx5kosH08f3A8VSTiLFOQOePZngZDjG Ij/39hKuIJWmkRAjVbkKez5LYQc0RsoeXxS8umz2m7mneEfg0Gh19dgxyQfWPJ1rzvOJ COLYRXIcMyNhAArImgYmilDpKH3AGv291DHAX1+Xkz7MBrjhCI05+Zn3x278A0LgNAdN vDkw== X-Gm-Message-State: ANoB5plZDmhv3HAh/3xv69GxAsA3e+vyyfUxJsjIy0BlPWSW2BDsiRT+ kHjkJZ1DfPL0AeH0txGPy7A= X-Google-Smtp-Source: AA0mqf4tVap8UrMxJkwVRHlJMK4zQQF7wPByzkfxwa+BaScW8VYqL7fz4NDfg8QdSx0ROEXkzUqUPw== X-Received: by 2002:a17:902:bb98:b0:188:edd2:318c with SMTP id m24-20020a170902bb9800b00188edd2318cmr26622264pls.26.1671047708910; Wed, 14 Dec 2022 11:55:08 -0800 (PST) Original-Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id c9-20020a170903234900b0018c7a5e052asm2218248plh.225.2022.12.14.11.55.08 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Dec 2022 11:55:08 -0800 (PST) In-Reply-To: <5HEX4A0JH8fd_VGG1FbzJ8QtBZXlHLKtuAGgc_TUHvzKCzU2Q3PYbbi3rUWeLOBoJzg0qsQgVhwGZCF86A2Xg--I2ep5d1KjKoUoHrxXpqA=@rjt.dev> X-Mailer: Apple Mail (2.3696.120.41.1.1) 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:250991 Archived-At: > On Dec 14, 2022, at 8:21 AM, Randy Taylor wrote: >=20 > On Wednesday, December 14th, 2022 at 07:02, Eli Zaretskii = wrote: >>=20 >>> Date: Tue, 13 Dec 2022 19:39:18 +0000 >>=20 >>> From: Randy Taylor dev@rjt.dev >>> Cc: 60025@debbugs.gnu.org, theo@thornhill.no, casouri@gmail.com >>>=20 >>> +** New major mode 'go-mod-ts-mode'. >>> +A major mode based on the tree-sitter library for editing go.mod >>> +files. It includes support for font-locking and indentation. This >>> +mode will be auto-enabled for go.mod files. >>=20 >>=20 >> Please quote go.mod as 'go.mod' (we quote file names and symbols in >> NEWS). >>=20 >> Otherwise, this LGTM, thanks. >>=20 >=20 > Thanks, here's the new patch. I double-quoted it since that's what = other file names and extensions have in NEWS - hopefully that's right. = Assuming that's OK, should be good to install. >=20 > Yuan, did you see my original post in this thread? I'm wondering how = to go about tackling that indentation problem (I'm probably missing = something very simple and obvious). Ah, oops, replies below: > I am having a tiny bit of trouble with a go.mod indentation rule. = Using the patch, create a go.mod file anywhere, activate go-mod-ts-mode = and add the following: >=20 > require () >=20 > Place point inside the parens, and then hit enter. The expectation is = that point will end up indented inside that block. If you add the text = "test v1.0.0" and hit TAB, it will indent properly (and if you hit enter = after that text it will indent properly for the next entry). If you go = to the end of the line for the top paren and hit enter, it will not = indent (and we want it to). It seems to give us no-node in that = circumstance. Is there a simple indent rule that can match exactly that = that I'm missing? I think you can just test for the parent? In C, if point is at an empty = line after a statement in a block, like this: int main() { return 0; | } The matched rule is (parent-is =E2=80=9Ccompond_statement=E2=80=9D), = where compound_statement is the block. In your case, I guess you can = test if parent is the argument list. Yuan=