1

This is more or less a question of putting the answer from Make web-mode always indent with spaces into the use-package declaration.

I want to set tab indent to 2 spaces, and use the spaces throughout the lines, even when reaching 8 spaces etc.

This is my effort so far, I've tried both setq and setq-default, and I've tried to put the init code in either :config or :init, but it's not working. When I "describe variable", tab-width is always 8 in the .go file that I'm opening.

(use-package go-mode
  :mode "\\.go\\'"
  :config
  (progn
    (setq-default tab-width 2)
    (setq-default indent-tabs-mode nil)
    ;; tab-width & indent-tabs-mode are both buffer-local so need setq-default
    )

  :init
  (progn
    (setq-default tab-width 2)
    (setq-default indent-tabs-mode nil)
    )

  )
xpt
  • 447
  • 3
  • 16

1 Answers1

2

The most go specific way to do it is using a go-mode-hook.

In your :config add something like (add-hook 'go-mode-hook (lambda () (setq tab-width 2))) That way you set it for every go buffer you open.

Jordon Biondo
  • 12,332
  • 2
  • 41
  • 62