* bug#75362: 29.4; go-ts-mode.el: wrong indentation inside var list
@ 2025-01-04 15:40 Roi Martin
2025-01-05 22:05 ` Randy Taylor
0 siblings, 1 reply; 2+ messages in thread
From: Roi Martin @ 2025-01-04 15:40 UTC (permalink / raw)
To: 75362
When using the Go tree-sitter grammar v0.23.4 from
https://github.com/tree-sitter/tree-sitter-go.git, indentation inside
var lists does not work correctly.
For instance, the following code is indented as:
```
var (
one = 1
)
```
Instead of:
```
var (
one = 1
)
```
Just in case it can help, I think this stopped working with grammar
version `v0.21.1`, that introduced `var_spec_list`:
https://github.com/tree-sitter/tree-sitter-go/compare/v0.21.0...v0.21.1
Please, take it with a pinch of salt because I'm not very familiar with
tree-sitter.
In GNU Emacs 29.4 (build 1, x86_64-redhat-linux-gnu, GTK+ Version
3.24.43, cairo version 1.18.0) of 2024-10-10 built on
4825182c94fc4195b65c80c30f523a16
System Description: Fedora Linux 41 (Workstation Edition)
Configured using:
'configure --build=x86_64-redhat-linux-gnu
--host=x86_64-redhat-linux-gnu --program-prefix=
--disable-dependency-tracking --prefix=/usr --exec-prefix=/usr
--bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc
--datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib64
--libexecdir=/usr/libexec --localstatedir=/var --runstatedir=/run
--sharedstatedir=/var/lib --mandir=/usr/share/man
--infodir=/usr/share/info --with-cairo --with-dbus --with-gif
--with-gpm=no --with-harfbuzz --with-jpeg --with-json --with-modules
--with-native-compilation=aot --with-pgtk --with-png --with-rsvg
--with-sqlite3 --with-tiff --with-tree-sitter --with-webp --with-xpm
build_alias=x86_64-redhat-linux-gnu host_alias=x86_64-redhat-linux-gnu
CC=gcc 'CFLAGS=-DMAIL_USE_LOCKF -O2 -flto=auto -ffat-lto-objects
-fexceptions -g -grecord-gcc-switches -pipe -Wall
-Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3
-Wp,-D_GLIBCXX_ASSERTIONS
-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong
-specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -march=x86-64
-mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection
-fcf-protection -mtls-dialect=gnu2 -fno-omit-frame-pointer
-mno-omit-leaf-frame-pointer ' 'LDFLAGS=-Wl,-z,relro -Wl,--as-needed
-Wl,-z,pack-relative-relocs -Wl,-z,now
-specs=/usr/lib/rpm/redhat/redhat-hardened-ld
-specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1
-specs=/usr/lib/rpm/redhat/redhat-package-notes '
PKG_CONFIG_PATH=:/usr/lib64/pkgconfig:/usr/share/pkgconfig CXX=g++
'CXXFLAGS=-O2 -flto=auto -ffat-lto-objects -fexceptions -g
-grecord-gcc-switches -pipe -Wall -Werror=format-security
-Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS
-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong
-specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -march=x86-64
-mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection
-fcf-protection -mtls-dialect=gnu2 -fno-omit-frame-pointer
-mno-omit-leaf-frame-pointer ''
Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON
LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY
PDUMPER PGTK PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF
TOOLKIT_SCROLL_BARS TREE_SITTER WEBP XIM GTK3 ZLIB
Important settings:
value of $LC_MONETARY: en_IE.UTF-8
value of $LC_NUMERIC: en_IE.UTF-8
value of $LC_TIME: en_IE.UTF-8
value of $LANG: en_US.UTF-8
value of $XMODIFIERS: @im=ibus
locale-coding-system: utf-8-unix
Major mode: Go
Minor modes in effect:
eglot--managed-mode: t
flymake-mode: t
denote-menu-bar-mode: t
server-mode: t
icomplete-mode: t
fido-mode: t
tooltip-mode: t
global-eldoc-mode: t
eldoc-mode: t
show-paren-mode: t
electric-indent-mode: t
mouse-wheel-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
blink-cursor-mode: t
column-number-mode: t
line-number-mode: t
indent-tabs-mode: t
transient-mark-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
Load-path shadows:
/home/n/.emacs.d/elpa/transient-20250103.1731/transient hides /usr/share/emacs/29.4/lisp/transient
Features:
(shadow sort mail-extr emacsbug message puny rfc822 mml mml-sec epa
derived epg rfc6068 epg-config gnus-util mm-decode mm-bodies mm-encode
mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047
rfc2045 ietf-drums mm-util mail-prsvr mail-utils yank-media
markdown-mode color noutline outline time-date files-x find-dired grep
eglot external-completion array filenotify jsonrpc ert ewoc debug
backtrace find-func flymake-proc flymake thingatpt compile
text-property-search comint ansi-osc ansi-color imenu go-ts-mode treesit
dired-aux denote xref project ring comp comp-cstr warnings cl-extra
help-mode server rx dired dired-loaddefs icomplete cus-edit pp cus-load
icons wid-edit easy-mmode clang-rename clang-include-fixer let-alist
clang-format xml denote-autoloads elfeed-autoloads forge-autoloads
closql-autoloads emacsql-autoloads geiser-chez-autoloads
geiser-guile-autoloads geiser-autoloads ghub-autoloads htmlize-autoloads
magit-autoloads pcase magit-section-autoloads dash-autoloads
markdown-mode-autoloads racket-mode-autoloads tmr-autoloads
transient-autoloads treepy-autoloads with-editor-autoloads info
compat-autoloads yaml-autoloads zig-mode-autoloads reformatter-autoloads
package browse-url url url-proxy url-privacy url-expand url-methods
url-history url-cookie generate-lisp-file url-domsuf url-util mailcap
url-handlers url-parse auth-source cl-seq eieio eieio-core cl-macs
password-cache json subr-x map byte-opt gv bytecomp byte-compile
url-vars cl-loaddefs cl-lib rmc iso-transl tooltip cconv eldoc paren
electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel
term/pgtk-win pgtk-win term/common-win pgtk-dnd tool-bar dnd fontset
image regexp-opt fringe tabulated-list replace newcomment text-mode
lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch
easymenu timer select scroll-bar mouse jit-lock font-lock syntax
font-core term/tty-colors frame minibuffer nadvice seq simple cl-generic
indonesian philippine cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
composite emoji-zwj charscript charprop case-table epa-hook
jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs
theme-loaddefs faces cus-face macroexp files window text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget keymap
hashtable-print-readable backquote threads dbusbind inotify
dynamic-setting system-font-setting font-render-setting cairo gtk pgtk
multi-tty make-network-process native-compile emacs)
Memory information:
((conses 16 198588 19413)
(symbols 48 16484 6)
(strings 32 50057 3480)
(string-bytes 1 1645981)
(vectors 16 31794)
(vector-slots 8 605866 18429)
(floats 8 196 642)
(intervals 56 753 136)
(buffers 984 20))
^ permalink raw reply [flat|nested] 2+ messages in thread
* bug#75362: 29.4; go-ts-mode.el: wrong indentation inside var list
2025-01-04 15:40 bug#75362: 29.4; go-ts-mode.el: wrong indentation inside var list Roi Martin
@ 2025-01-05 22:05 ` Randy Taylor
0 siblings, 0 replies; 2+ messages in thread
From: Randy Taylor @ 2025-01-05 22:05 UTC (permalink / raw)
To: Roi Martin; +Cc: 75362
[-- Attachment #1: Type: text/plain, Size: 762 bytes --]
On Saturday, January 4th, 2025 at 10:40, Roi Martin <jroi.martin@gmail.com> wrote:
>
> When using the Go tree-sitter grammar v0.23.4 from
> https://github.com/tree-sitter/tree-sitter-go.git, indentation inside
> var lists does not work correctly.
>
> For instance, the following code is indented as:
>
> `var ( one = 1 )`
>
> Instead of:
>
> `var ( one = 1 )`
>
> Just in case it can help, I think this stopped working with grammar
> version `v0.21.1`, that introduced `var_spec_list`:
>
> https://github.com/tree-sitter/tree-sitter-go/compare/v0.21.0...v0.21.1
>
> Please, take it with a pinch of salt because I'm not very familiar with
> tree-sitter.
>
> [...]
>
Thanks for the report.
The attached patch fixes it for me.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-go-ts-mode-var-spec-indentation-Bug-75362.patch --]
[-- Type: text/x-patch; name=0001-Fix-go-ts-mode-var-spec-indentation-Bug-75362.patch, Size: 1010 bytes --]
From ecb80b849c3bc490085a4146b8f8d499949220c2 Mon Sep 17 00:00:00 2001
From: Randy Taylor <dev@rjt.dev>
Date: Sun, 5 Jan 2025 16:48:00 -0500
Subject: [PATCH] Fix go-ts-mode var spec indentation (Bug#75362)
v0.21.1 and onwards changed how this was indented.
* lisp/progmodes/go-ts-mode.el (go-ts-mode--indent-rules):
Add rule for var_spec_list.
---
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 747bf9a9da8..ccfdcb909e5 100644
--- a/lisp/progmodes/go-ts-mode.el
+++ b/lisp/progmodes/go-ts-mode.el
@@ -106,6 +106,7 @@ go-ts-mode--indent-rules
((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)
+ ((parent-is "var_spec_list") parent-bol go-ts-mode-indent-offset)
(no-node parent-bol 0)))
"Tree-sitter indent rules for `go-ts-mode'.")
--
2.47.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-01-05 22:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-04 15:40 bug#75362: 29.4; go-ts-mode.el: wrong indentation inside var list Roi Martin
2025-01-05 22:05 ` Randy Taylor
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).