From 005831bfcc1301e62d9a939cb905767b466200e5 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 9 Sep 2024 16:08:06 -0400 Subject: [PATCH] refactor(lsp): let lsp-mode load lsp client packages Most of these lsp packages are already in `lsp-client-packages`, which lsp-mode will eagerly load the first time `lsp-mode` is activated, so we don't need to do it ourselves, except in cases where the package isn't in `lsp-client-packages` (like lsp-julia). --- modules/lang/cc/config.el | 3 --- modules/lang/haskell/config.el | 1 - modules/lang/java/+lsp.el | 2 +- modules/lang/julia/config.el | 6 ++++-- modules/lang/python/config.el | 2 +- modules/lang/swift/config.el | 5 +++-- 6 files changed, 9 insertions(+), 10 deletions(-) diff --git a/modules/lang/cc/config.el b/modules/lang/cc/config.el index d24c155e7..3a6e1cd64 100644 --- a/modules/lang/cc/config.el +++ b/modules/lang/cc/config.el @@ -191,9 +191,6 @@ This is ignored by ccls.") (add-to-list 'projectile-globally-ignored-directories "^.ccls-cache$") (add-to-list 'projectile-project-root-files-bottom-up ".ccls-root") (add-to-list 'projectile-project-root-files-top-down-recurring "compile_commands.json")) - ;; Avoid using `:after' because it ties the :config below to when `lsp-mode' - ;; loads, rather than `ccls' loads. - (after! lsp-mode (require 'ccls)) :config (set-evil-initial-state! 'ccls-tree-mode 'emacs) (set-lsp-priority! 'ccls -2) ; Prioritize clangd over ccls diff --git a/modules/lang/haskell/config.el b/modules/lang/haskell/config.el index 20752918b..9c78fbced 100644 --- a/modules/lang/haskell/config.el +++ b/modules/lang/haskell/config.el @@ -53,7 +53,6 @@ :init (add-hook 'haskell-mode-local-vars-hook #'lsp! 'append) (add-hook 'haskell-literate-mode-local-vars-hook #'lsp! 'append) - (after! lsp-mode (require 'lsp-haskell)) :config ;; Does some strange indentation if it pastes in the snippet (setq-hook! 'haskell-mode-hook yas-indent-line 'fixed)) diff --git a/modules/lang/java/+lsp.el b/modules/lang/java/+lsp.el index f681f9515..3fc072b74 100644 --- a/modules/lang/java/+lsp.el +++ b/modules/lang/java/+lsp.el @@ -2,7 +2,7 @@ ;;;###if (and (modulep! +lsp) (not (modulep! :tools lsp +eglot))) (use-package! lsp-java - :after lsp-mode + :defer t :preface (setq lsp-java-workspace-dir (concat doom-data-dir "java-workspace")) (add-hook 'java-mode-local-vars-hook #'lsp! 'append) diff --git a/modules/lang/julia/config.el b/modules/lang/julia/config.el index 08dc89471..462b42b10 100644 --- a/modules/lang/julia/config.el +++ b/modules/lang/julia/config.el @@ -76,8 +76,10 @@ (use-package! lsp-julia :when (modulep! +lsp) :unless (modulep! :tools lsp +eglot) - :after lsp-mode - :preface (setq lsp-julia-default-environment nil) + :defer t + :preface + (after! lsp-mode (add-to-list 'lsp-client-packages 'lsp-julia)) + (setq lsp-julia-default-environment nil) :init ;; If no environment is set, then auto-detect one in ~/.julia/environments/, ;; falling back to `lsp-julia-default-environment's default. diff --git a/modules/lang/python/config.el b/modules/lang/python/config.el index 657fcef77..a68672366 100644 --- a/modules/lang/python/config.el +++ b/modules/lang/python/config.el @@ -353,7 +353,7 @@ :when (modulep! +lsp) :when (modulep! +pyright) :when (not (modulep! :tools lsp +eglot)) - :after lsp-mode + :defer t :init (when-let ((exe (executable-find "basedpyright"))) (setq lsp-pyright-langserver-command exe))) diff --git a/modules/lang/swift/config.el b/modules/lang/swift/config.el index ab66f2c48..fd9024458 100644 --- a/modules/lang/swift/config.el +++ b/modules/lang/swift/config.el @@ -26,8 +26,9 @@ (use-package! lsp-sourcekit - :when (and (modulep! +lsp) (not (modulep! :tools lsp +eglot))) - :after swift-mode + :when (modulep! +lsp) + :when (not (modulep! :tools lsp +eglot)) + :defer t :init (add-hook 'swift-mode-local-vars-hook #'lsp! 'append) :config (set-formatter! 'swiftformat '("swiftformat" "--output" "stdout"))