|
From: | BTuin |
Subject: | Re: In go-ts-mode, tab-width 4 inserts two tabs instead of one |
Date: | Tue, 26 Sep 2023 13:36:58 +0200 |
User-agent: | Mozilla Thunderbird |
Le 26/09/2023 à 13:08, Pankaj Jangid a écrit :
Suppose I have this struct, #+begin_src go package main type Message struct { Response Response Request Request ForAPI string } #+end_src If I keep default tab-width of 8, then it works fine. But when I change the buffer local variable tab-width to 4, /mostly/ it inserts two tab chars instead of one, /sometimes/ it works fine. I have one file where it works just fine. And in all other files, it inserts two tabs instead of one. I am on branch emacs-29 and built with tree-sitter and gtk. Language mode is go-ts-mode.
That's because tab-width only controls the appearance of a tabulation. It doesn't change the actual indentation offset. In go-ts-mode, the indentation offset is set by the variable go-ts-mode-indent-offset. Since it is 8 by default and that you have set tab-width to 4, it inserts two tabs to keep the offset of 8.
So you simply need to set go-ts-mode-indent-offset to 4 or directly to tab-width (with (setq go-ts-mode-indent-offset tab-width)).
[Prev in Thread] | Current Thread | [Next in Thread] |