mirror of
https://github.com/doomemacs/doomemacs
synced 2025-08-03 12:27:26 -05:00
lang/go: use gofmt for partials
goimports (if available) doesn't play well with partial code reformatting.
This commit is contained in:
@ -12,11 +12,13 @@
|
|||||||
:references #'go-guru-referrers
|
:references #'go-guru-referrers
|
||||||
:documentation #'godoc-at-point)
|
:documentation #'godoc-at-point)
|
||||||
|
|
||||||
(set-formatter! 'go-mode #'gofmt)
|
;; Redefines default formatter to *not* use goimports if reformatting a
|
||||||
(when-let* ((goimports (executable-find "goimports")))
|
;; region; as it doesn't play well with partial code.
|
||||||
(setq gofmt-command goimports))
|
(set-formatter! 'gofmt
|
||||||
(when (featurep! :feature syntax-checker)
|
'(("%s" (if (or (use-region-p)
|
||||||
(setq gofmt-show-errors nil)) ; Leave it to flycheck
|
(not (executable-find "goimports")))
|
||||||
|
"gofmt"
|
||||||
|
"goimports"))))
|
||||||
|
|
||||||
(add-hook 'go-mode-hook #'go-eldoc-setup)
|
(add-hook 'go-mode-hook #'go-eldoc-setup)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user