diff options
author | Alan Pearce | 2024-05-16 18:01:16 +0200 |
---|---|---|
committer | Alan Pearce | 2024-05-16 18:01:42 +0200 |
commit | 18ed3572ae444dbbb8e64adbc29639290cbadb21 (patch) | |
tree | a156c987b66f54b1e3c2d22cef8531181ab37b83 | |
parent | f134b702150f49f8ecaac7d3a1948422fd182592 (diff) | |
download | nixfiles-18ed3572ae444dbbb8e64adbc29639290cbadb21.tar.lz nixfiles-18ed3572ae444dbbb8e64adbc29639290cbadb21.tar.zst nixfiles-18ed3572ae444dbbb8e64adbc29639290cbadb21.zip |
emacs: use lsp-mode for go to support secondary language server
-rw-r--r-- | user/emacs/init.el | 32 | ||||
-rw-r--r-- | user/settings/emacs.nix | 7 |
2 files changed, 36 insertions, 3 deletions
diff --git a/user/emacs/init.el b/user/emacs/init.el index 0a8663b3..f4995688 100644 --- a/user/emacs/init.el +++ b/user/emacs/init.el @@ -3,7 +3,8 @@ (defvar default-file-name-handler-alist file-name-handler-alist) (setq file-name-handler-alist nil gc-cons-threshold most-positive-fixnum - gc-cons-percentage 0.6) + gc-cons-percentage 0.6 + read-process-output-max (* 4 1024 1024)) (defun set-max-gc-cons () (setq gc-cons-threshold most-positive-fixnum)) (defun set-default-gc-cons () @@ -1045,7 +1046,6 @@ _C-k_: prev _u_pper _=_: upper/lower _s_mart resolve yaml-mode-hook js-base-mode-hook css-base-mode-hook - go-mode-hook lua-mode-hook nim-mode-hook html-mode-hook @@ -1085,6 +1085,34 @@ _C-k_: prev _u_pper _=_: upper/lower _s_mart resolve :commands (consult-eglot-symbols) :after eglot) +(use-package lsp-mode + :defer 3 + :ghook ('(go-mode-hook) + #'lsp-deferred) + ('lsp-mode-hook #'lsp-enable-which-key-integration) + :config (progn + (setq lsp-auto-guess-root t + lsp-auto-execute-action nil + lsp-headerline-breadcrumb-enable nil + lsp-enable-suggest-server-download nil) + + (lsp-register-custom-settings + '(("golangci-lint.command" + ["golangci-lint" "run" "--out-format" "json" "--issues-exit-code=1"]))) + + (lsp-register-client + (make-lsp-client :new-connection (lsp-stdio-connection + '("golangci-lint-langserver")) + :activation-fn (lsp-activate-on "go") + :language-id "go" + :priority 0 + :server-id 'golangci-lint + :add-on? t + :library-folders-fn #'lsp-go--library-default-directories + :initialization-options (lambda () + (gethash "golangci-lint" + (lsp-configuration-section "golangci-lint"))))))) + ;; Inside a javascript project, it's common to install tools locally to ;; the project. This will allows emacs to find their executables. diff --git a/user/settings/emacs.nix b/user/settings/emacs.nix index 722a7a6d..9615f9d1 100644 --- a/user/settings/emacs.nix +++ b/user/settings/emacs.nix @@ -127,6 +127,7 @@ in justl kind-icon lua-mode + lsp-mode lispyville magit markdown-mode @@ -155,7 +156,7 @@ in ws-butler which-key ]); - overrides = self: super: rec { + overrides = self: super: { apheleia = self.melpaPackages.apheleia.overrideAttrs (old: { patchPhase = '' @@ -163,8 +164,12 @@ in --replace-fail '"prettier"' '"prettierd"' ''; }); + lsp-mode = self.melpaPackages.lsp-mode.overrideAttrs { + LSP_USE_PLISTS = "true"; # sync with below + }; }; extraConfig = '' + (setenv "LSP_USE_PLISTS" "true") ; sync with above (with-eval-after-load 'editorconfig (setq editorconfig-exec-path "${pkgs.editorconfig-core-c}/bin/editorconfig")) (when (featurep 'native-compile) |