Subject: bug#75785: 30.0.93: grouped type declarations fail to indent in go-ts-mode

From: Randy Taylor <[email-masked]>
Date: Thu, 23 Jan 2025 16:22:37 +0000

On Thursday, January 23rd, 2025 at 09:56, Eli Zaretskii <[email-masked]> wrote:
> 
> 
> > Date: Thu, 23 Jan 2025 13:09:45 +0000
> 
> > From: Gerard Vermeulen [email-masked]
> > 
> > Hi,
> > 
> > Automatic indenting when typing works in go-ts-mode for grouped
> > var declarations like:
> > 
> > var (
> > a = 1
> > b = 2
> > )
> > 
> > but not for type declarations (taken from
> > https://github.com/uber-go/guide/blob/master/style.md#group-similar-declarations
> > ) like:
> > 
> > type (
> > Area float64
> > Volume float64
> > )
> > 
> > where I have to add the tabs (or spaces) myself.
> > I tried to change "type_spec" to "type_spec_list" in the defvar
> > go-ts-mode--indent-rules expression, but that did not fix it.
> > 
> > I am using a recent 30.0.93 git checkout.
> > 
> > Can it be fixed?
> 
> 
> Randy and Yuan, could you please look into this?

Thanks for the report.

The attached patch fixes it for me.

From 8f25f2678f0837f7a67ae60852e289cc3cffdc0e Mon Sep 17 00:00:00 2001
From: Randy Taylor <[email-masked]>
Date: Thu, 23 Jan 2025 11:16:34 -0500
Subject: [PATCH] Fix go-ts-mode type declaration indentation (Bug#75785)

* lisp/progmodes/go-ts-mode.el (go-ts-mode--indent-rules):
Add rule for type_declaration.
---
 lisp/progmodes/go-ts-mode.el | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lisp/progmodes/go-ts-mode.el b/lisp/progmodes/go-ts-mode.el
index ccfdcb909e5..ef2af3cd5af 100644
--- a/lisp/progmodes/go-ts-mode.el
+++ b/lisp/progmodes/go-ts-mode.el
@@ -103,6 +103,7 @@ go-ts-mode--indent-rules
      ((parent-is "parameter_list") parent-bol go-ts-mode-indent-offset)
      ((parent-is "select_statement") parent-bol 0)
      ((parent-is "type_case") parent-bol go-ts-mode-indent-offset)
+     ((parent-is "type_declaration") parent-bol go-ts-mode-indent-offset)
      ((parent-is "type_spec") parent-bol go-ts-mode-indent-offset)
      ((parent-is "type_switch_statement") parent-bol 0)
      ((parent-is "var_declaration") parent-bol go-ts-mode-indent-offset)
-- 
2.48.1