GNU bug report logs -
#75362
29.4; go-ts-mode.el: wrong indentation inside var list
Previous Next
Reported by: Roi Martin <jroi.martin <at> gmail.com>
Date: Sat, 4 Jan 2025 17:47:02 UTC
Severity: normal
Found in version 29.4
Done: Yuan Fu <casouri <at> gmail.com>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 75362 in the body.
You can then email your comments to 75362 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#75362
; Package
emacs
.
(Sat, 04 Jan 2025 17:47:03 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Roi Martin <jroi.martin <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Sat, 04 Jan 2025 17:47:03 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
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))
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#75362
; Package
emacs
.
(Sun, 05 Jan 2025 22:06:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 75362 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On Saturday, January 4th, 2025 at 10:40, Roi Martin <jroi.martin <at> 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.
[0001-Fix-go-ts-mode-var-spec-indentation-Bug-75362.patch (text/x-patch, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#75362
; Package
emacs
.
(Wed, 08 Jan 2025 06:20:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 75362 <at> debbugs.gnu.org (full text, mbox):
> On Jan 5, 2025, at 2:05 PM, Randy Taylor <dev <at> rjt.dev> wrote:
>
> On Saturday, January 4th, 2025 at 10:40, Roi Martin <jroi.martin <at> 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.<0001-Fix-go-ts-mode-var-spec-indentation-Bug-75362.patch>
Thanks Randy. Eli, should we apply this to emacs-30.
Also, what’s the general situation of grammar fixes on emacs-30? I’m asking because I fixed a grammar compatibility issue for cmake-ts-mode on master. I was going to back port it for 30.2, but it seems that simple fixes are ok for emacs-30?
Yuan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#75362
; Package
emacs
.
(Wed, 08 Jan 2025 13:03:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 75362 <at> debbugs.gnu.org (full text, mbox):
> Cc: 75362 <at> debbugs.gnu.org, Roi Martin <jroi.martin <at> gmail.com>
> From: Yuan Fu <casouri <at> gmail.com>
> Date: Tue, 7 Jan 2025 22:18:53 -0800
>
> > The attached patch fixes it for me.<0001-Fix-go-ts-mode-var-spec-indentation-Bug-75362.patch>
>
> Thanks Randy. Eli, should we apply this to emacs-30.
Is this backward-compatible to older grammars? If yes, it's okay to
install on emacs-30. If it is not compatible, I'd like to see how a
compatible patch will look before I decide.
> Also, what’s the general situation of grammar fixes on emacs-30? I’m asking because I fixed a grammar compatibility issue for cmake-ts-mode on master. I was going to back port it for 30.2, but it seems that simple fixes are ok for emacs-30?
Please tell the commit, and I will look at it.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#75362
; Package
emacs
.
(Wed, 08 Jan 2025 13:21:01 GMT)
Full text and
rfc822 format available.
Message #17 received at 75362 <at> debbugs.gnu.org (full text, mbox):
On Wednesday, January 8th, 2025 at 08:02, Eli Zaretskii <eliz <at> gnu.org> wrote:
>
>
> > Cc: 75362 <at> debbugs.gnu.org, Roi Martin jroi.martin <at> gmail.com
>
> > From: Yuan Fu casouri <at> gmail.com
> > Date: Tue, 7 Jan 2025 22:18:53 -0800
> >
> > > The attached patch fixes it for me.<0001-Fix-go-ts-mode-var-spec-indentation-Bug-75362.patch>
> >
> > Thanks Randy. Eli, should we apply this to emacs-30.
>
>
> Is this backward-compatible to older grammars? If yes, it's okay to
> install on emacs-30. If it is not compatible, I'd like to see how a
> compatible patch will look before I decide.
Yes, it's backward-compatible.
>
> > Also, what’s the general situation of grammar fixes on emacs-30? I’m asking because I fixed a grammar compatibility issue for cmake-ts-mode on master. I was going to back port it for 30.2, but it seems that simple fixes are ok for emacs-30?
>
>
> Please tell the commit, and I will look at it.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#75362
; Package
emacs
.
(Thu, 09 Jan 2025 07:11:01 GMT)
Full text and
rfc822 format available.
Message #20 received at 75362 <at> debbugs.gnu.org (full text, mbox):
> Date: Wed, 08 Jan 2025 13:20:19 +0000
> From: Randy Taylor <dev <at> rjt.dev>
> Cc: Yuan Fu <casouri <at> gmail.com>, 75362 <at> debbugs.gnu.org, jroi.martin <at> gmail.com
>
> On Wednesday, January 8th, 2025 at 08:02, Eli Zaretskii <eliz <at> gnu.org> wrote:
> >
> >
> > > Cc: 75362 <at> debbugs.gnu.org, Roi Martin jroi.martin <at> gmail.com
> >
> > > From: Yuan Fu casouri <at> gmail.com
> > > Date: Tue, 7 Jan 2025 22:18:53 -0800
> > >
> > > > The attached patch fixes it for me.<0001-Fix-go-ts-mode-var-spec-indentation-Bug-75362.patch>
> > >
> > > Thanks Randy. Eli, should we apply this to emacs-30.
> >
> >
> > Is this backward-compatible to older grammars? If yes, it's okay to
> > install on emacs-30. If it is not compatible, I'd like to see how a
> > compatible patch will look before I decide.
>
> Yes, it's backward-compatible.
OK, then, Yuan, please feel free to install on emacs-30.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#75362
; Package
emacs
.
(Fri, 10 Jan 2025 03:12:01 GMT)
Full text and
rfc822 format available.
Message #23 received at 75362 <at> debbugs.gnu.org (full text, mbox):
> On Jan 8, 2025, at 11:10 PM, Eli Zaretskii <eliz <at> gnu.org> wrote:
>
>> Date: Wed, 08 Jan 2025 13:20:19 +0000
>> From: Randy Taylor <dev <at> rjt.dev>
>> Cc: Yuan Fu <casouri <at> gmail.com>, 75362 <at> debbugs.gnu.org, jroi.martin <at> gmail.com
>>
>> On Wednesday, January 8th, 2025 at 08:02, Eli Zaretskii <eliz <at> gnu.org> wrote:
>>>
>>>
>>>> Cc: 75362 <at> debbugs.gnu.org, Roi Martin jroi.martin <at> gmail.com
>>>
>>>> From: Yuan Fu casouri <at> gmail.com
>>>> Date: Tue, 7 Jan 2025 22:18:53 -0800
>>>>
>>>>> The attached patch fixes it for me.<0001-Fix-go-ts-mode-var-spec-indentation-Bug-75362.patch>
>>>>
>>>> Thanks Randy. Eli, should we apply this to emacs-30.
>>>
>>>
>>> Is this backward-compatible to older grammars? If yes, it's okay to
>>> install on emacs-30. If it is not compatible, I'd like to see how a
>>> compatible patch will look before I decide.
>>
>> Yes, it's backward-compatible.
>
> OK, then, Yuan, please feel free to install on emacs-30.
Installed.
As for cmake-ts-mode’s fix, it’s in 4def541bbfe67b1a492e8a3b6041a1d8f76d680b
Basically, tree-sitter-cmake gives up on parsing cmake generator expressions. According to the commit message:
> feat!: remove parsing generator expressions
>
> Parsing generator expressions statically is impossible since whether an argument is interpreted as a generator expression or not depends on the function itself. Hence, the parsing for it is removed.
>
Which makes sense to me. The fix is backward-compatible too, since we’re just removing fontification for angle brackets.
Yuan
Reply sent
to
Yuan Fu <casouri <at> gmail.com>
:
You have taken responsibility.
(Mon, 13 Jan 2025 06:36:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Roi Martin <jroi.martin <at> gmail.com>
:
bug acknowledged by developer.
(Mon, 13 Jan 2025 06:36:02 GMT)
Full text and
rfc822 format available.
Message #28 received at 75362-done <at> debbugs.gnu.org (full text, mbox):
> On Jan 4, 2025, at 7:40 AM, Roi Martin <jroi.martin <at> 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 Roi, and especially thanks for finding the change in grammar!
The good news is, I just checked and it’s fixed in Emacs 30. Before then, something like this should fix it for you:
(add-hook 'go-ts-mode-hook #'fix-go-ts-mode-indentation)
(defun fix-go-ts-mode-indentation ()
(setf (alist-get 'go treesit-simple-indent-rules)
(append (alist-get 'go treesit-simple-indent-rules)
'(((parent-is "var_spec_list") parent-bol go-ts-mode-indent-offset)))))
Yuan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#75362
; Package
emacs
.
(Tue, 14 Jan 2025 05:28:01 GMT)
Full text and
rfc822 format available.
Message #31 received at 75362-done <at> debbugs.gnu.org (full text, mbox):
Yuan Fu <casouri <at> gmail.com> writes:
> Thanks Roi, and especially thanks for finding the change in grammar!
>
> The good news is, I just checked and it’s fixed in Emacs 30. Before then, something like this should fix it for you:
>
> (add-hook 'go-ts-mode-hook #'fix-go-ts-mode-indentation)
> (defun fix-go-ts-mode-indentation ()
> (setf (alist-get 'go treesit-simple-indent-rules)
> (append (alist-get 'go treesit-simple-indent-rules)
> '(((parent-is "var_spec_list") parent-bol go-ts-mode-indent-offset)))))
Great! Thanks a lot for landing a fix and providing a workaround!
Roi
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Tue, 11 Feb 2025 12:24:10 GMT)
Full text and
rfc822 format available.
This bug report was last modified 207 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.