From f05512c2e5915523cd85f24435eb9674556cc02d Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 20 Sep 2019 14:49:39 -0400 Subject: [PATCH] lang/rust: restore advice redefs Update package-installed-p redefinition to use a safe `require`, so that rustic-setup-rls will fail gracefully if lsp/eglot aren't available. And restore rustic-install-rls-client-p redefinition to prevent rustic from trying to install packages. --- modules/lang/rust/config.el | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/modules/lang/rust/config.el b/modules/lang/rust/config.el index 1d2b8bdfb..92fd8fc15 100644 --- a/modules/lang/rust/config.el +++ b/modules/lang/rust/config.el @@ -56,11 +56,18 @@ (defadvice! +rust--dont-install-packages-p (orig-fn &rest args) :around #'rustic-setup-rls - (cl-letf (;; `rustic-setup-rls' uses `package-installed-p' unnecessarily, to - ;; try to detect rls. This breaks because Doom lazy loads - ;; package.el, and doesn't use package.el to begin with. + (cl-letf (;; `rustic-setup-rls' uses `package-installed-p' to determine if + ;; lsp-mode/elgot are available. This breaks because Doom doesn't + ;; use package.el to begin with (and lazy loads it). ((symbol-function #'package-installed-p) - (symbol-function #'identity))) + (lambda (pkg) + (require pkg nil t))) + ;; If lsp/elgot isn't available, it attempts to install lsp-mode + ;; via package.el. Doom manages its own dependencies so we disable + ;; that behavior. + ((symbol-function #'rustic-install-rls-client-p) + (lambda (&rest _) + (message "No RLS server running.")))) (apply orig-fn args))))