summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAlan Pearce2024-05-02 19:44:42 +0200
committerAlan Pearce2024-05-02 19:44:42 +0200
commitdbc511cc2326c74dc6dba5b5a712ba3c52311f8e (patch)
treede0837c65bcee84f857b097080e0dbb8e0dbeddb
parent2c5665edeb0c5546e5e60d6ccb85731fe06bc83b (diff)
downloadnixfiles-dbc511cc2326c74dc6dba5b5a712ba3c52311f8e.tar.lz
nixfiles-dbc511cc2326c74dc6dba5b5a712ba3c52311f8e.tar.zst
nixfiles-dbc511cc2326c74dc6dba5b5a712ba3c52311f8e.zip
golang: install and configure lang servers
-rw-r--r--user/emacs/init.el13
-rw-r--r--user/settings/development/golang.nix2
2 files changed, 13 insertions, 2 deletions
diff --git a/user/emacs/init.el b/user/emacs/init.el
index 3cd6f853..7ccbe260 100644
--- a/user/emacs/init.el
+++ b/user/emacs/init.el
@@ -1040,9 +1040,16 @@ _C-k_: prev  _u_pper              _=_: upper/lower       _s_mart resolve
             (defun my/setup-eglot-eldoc ()
               (push 'flymake-eldoc-function eldoc-documentation-functions))
             (add-hook 'eglot-managed-mode-hook 'my/setup-eglot-eldoc)
+            (setf (alist-get '(go-mode go-dot-mod-mode go-dot-work-mode go-ts-mode go-mod-ts-mode)
+                             eglot-server-programs
+                             nil nil #'equal)
+                  (eglot-alternatives '("golangci-lint-langserver"
+                                        "gopls" )))
             (setq-default eglot-workspace-configuration
-                          '(:yaml (:keyOrdering nil)
-                                  :nix (:autoArchive t))
+                          '( :yaml (:keyOrdering nil)
+                             :nix (:autoArchive t)
+                             :gopls ( :staticcheck t
+                                      :usePlaceholders t))
                           eglot-ignored-server-capabilities '(:documentHighlightProvider))
             (defun my/eglot-capf ()
               (setq-local completion-at-point-functions
@@ -1095,6 +1102,8 @@ _C-k_: prev  _u_pper              _=_: upper/lower       _s_mart resolve
                   '("shfmt"))
             (setf (alist-get 'nixfmt apheleia-formatters)
                   '("nixpkgs-fmt"))
+            (setf (alist-get 'go-ts-mode apheleia-mode-alist)
+                  '(goimports))
             (add-hook 'apheleia-mode-hook #'turn-off-format-all-mode))
   :init (progn
           (apheleia-global-mode +1)))
diff --git a/user/settings/development/golang.nix b/user/settings/development/golang.nix
index b554bd5c..e5cd9199 100644
--- a/user/settings/development/golang.nix
+++ b/user/settings/development/golang.nix
@@ -4,6 +4,8 @@
     gopls
     gotools
     golines
+    golangci-lint
+    golangci-lint-langserver
   ];
   programs.emacs.extraPackages = epkgs: (with epkgs; [
     go-eldoc