summaryrefslogtreecommitdiff
path: root/lang/go.el
blob: 199053d95aebd1cc127617e8ee4ed5522ba67a27 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
;;; lang/go.el -*- lexical-binding: t; -*-

(defun +eglot-organize-imports ()
  (call-interactively 'eglot-code-action-organize-imports))

(when (featurep! :tools lsp +eglot)
  (after! eglot
    (add-to-list 'eglot-workspace-configuration
                 `((:gopls . ((staticcheck . t))))))

  (setq-hook! 'go-mode-hook +format-with :none)

  (add-hook! 'go-mode-hook
    (add-hook 'before-save-hook #'eglot-format-buffer -30 t)
    (add-hook 'before-save-hook #'+eglot-organize-imports -20 t)))