diff --git a/modules/tools/lsp/+eglot.el b/modules/tools/lsp/+eglot.el index badcd61dc..70f3c066d 100644 --- a/modules/tools/lsp/+eglot.el +++ b/modules/tools/lsp/+eglot.el @@ -55,6 +55,15 @@ server an expensive restart when its buffer is reverted." (funcall fn server)))) +(use-package! eglot-booster + :when (modulep! +booster) + :after eglot + :init + (setq eglot-booster-io-only t) + :config + (eglot-booster-mode +1)) + + (use-package! consult-eglot :when (modulep! :completion vertico) :defer t @@ -67,10 +76,3 @@ server an expensive restart when its buffer is reverted." (use-package! flycheck-eglot :when (modulep! :checkers syntax -flymake) :hook (eglot-managed-mode . flycheck-eglot-mode)) - -(use-package! eglot-booster - :when (modulep! +eglot +booster) - :after eglot - :config (eglot-booster-mode) - :init - (setq eglot-booster-io-only t)) diff --git a/modules/tools/lsp/+lsp.el b/modules/tools/lsp/+lsp.el index c7b4ed1ad..fa87289a4 100644 --- a/modules/tools/lsp/+lsp.el +++ b/modules/tools/lsp/+lsp.el @@ -164,20 +164,21 @@ server getting expensively restarted when reverting buffers." (add-hook 'lsp-mode-hook #'lsp-completion-mode)) (when (modulep! +booster) - (defun lsp-booster--advice-final-command (old-fn cmd &optional test?) + (defadvice! +lsp--booster-final-command-a (fn cmd &optional test?) "Prepend emacs-lsp-booster command to lsp CMD." - (let ((orig-result (funcall old-fn cmd test?))) + :around #'lsp-resolve-final-command + (let ((orig-result (funcall fn cmd test?))) (if (and (not test?) ;; for check lsp-server-present? (not (file-remote-p default-directory)) ;; see lsp-resolve-final-command, it would add extra shell wrapper (not (functionp 'json-rpc-connection)) ;; native json-rpc (executable-find "emacs-lsp-booster")) (progn - (when-let ((command-from-exec-path (executable-find (car orig-result)))) ;; resolve command from exec-path (in case not found in $PATH) + (when-let* ((command-from-exec-path (executable-find (car orig-result)))) ;; resolve command from exec-path (in case not found in $PATH) (setcar orig-result command-from-exec-path)) (message "Using emacs-lsp-booster for %s!" orig-result) (append '("emacs-lsp-booster" "--disable-bytecode" "--") orig-result)) - orig-result))) - (advice-add 'lsp-resolve-final-command :around #'lsp-booster--advice-final-command))) + orig-result))))) + (use-package! lsp-ui :hook (lsp-mode . lsp-ui-mode)