Update tools/lsp to reflect upstream changes

LSP has taken it upon themselves to aggressively install servers if they
are missing. No thanks. Promote deliberate use of lsp-install-server
where we can and load lsp-clients sooner.
This commit is contained in:
Henrik Lissner 2020-01-10 04:42:54 -05:00
parent 4acd60aba3
commit 46aaeee818
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -11,7 +11,7 @@ This can be a single company backend or a list thereof. It can be anything
;;; Packages
(use-package! lsp-mode
:defer t
:commands lsp-install-server
:init
(setq lsp-session-file (concat doom-etc-dir "lsp-session"))
;; Don't prompt the user for the project root every time we open a new
@ -27,6 +27,9 @@ This can be a single company backend or a list thereof. It can be anything
lsp-intelephense-storage-path (concat doom-cache-dir "lsp-intelephense/"))
:config
(when (and lsp-auto-configure lsp-auto-require-clients)
(require 'lsp-clients))
(set-lookup-handlers! 'lsp-mode :async t
:documentation 'lsp-describe-thing-at-point
:definition 'lsp-find-definition
@ -64,39 +67,35 @@ auto-killed (which is usually an expensive process)."
nil)
((lsp--find-root-interactively session))))
(defadvice! +lsp-init-a (&optional arg)
(defadvice! +lsp-init-a (orig-fn &optional arg)
"Enable `lsp-mode' in the current buffer.
Meant to be a lighter alternative to `lsp', which is too eager about
initializing lsp-ui-mode, company, yasnippet and flycheck. Instead, these have
been moved out to their respective modules, or these hooks:
Meant to gimp `lsp', which is too eager about installing LSP servers,
initializing lsp-ui-mode, company, yasnippet and flycheck. Instead, these are
handled by our modules. Also see:
+ `+lsp-init-company-h' (on `lsp-mode-hook')
+ `+lsp-init-ui-flycheck-or-flymake-h' (on `lsp-ui-mode-hook')
Also logs the resolved project root, if found."
:override #'lsp
This also logs the resolved project root, if found, so we know where we are."
:around #'lsp
(interactive "P")
(require 'lsp-mode)
(when lsp-auto-configure
(require 'lsp-clients))
(and (buffer-file-name)
(setq-local
lsp--buffer-workspaces
(or (lsp--try-open-in-library-workspace)
(lsp--try-project-root-workspaces
(equal arg '(4))
(and arg (not (equal arg 1))))))
(prog1 (lsp-mode 1)
;; Announce what project root we're using, for diagnostic purposes
(cl-letf
(;; Our system, our rules. Don't install things on it without our
;; permission. Use `lsp-install-server' deliberately, instead.
((symbol-function #'lsp--client-download-server-fn)
(lambda (&rest _) nil))
;; Don't set up company, lsp-ui, yasnippet, or flycheck. We have
;; modules dedicated to these things already.
((symbol-function #'lsp--auto-configure)
(lambda (&rest _)
;; Announce what project root we're using, for diagnostic
;; purposes
(if-let (root (lsp--calculate-root (lsp-session) (buffer-file-name)))
(lsp--info "Guessed project root is %s" (abbreviate-file-name root))
(lsp--info "Could not guess project root."))
(lsp--info "Connected to %s."
(apply #'concat
(mapcar
(lambda (it) (format "[%s]" (lsp--workspace-print it)))
lsp--buffer-workspaces))))))
(lsp--info "Could not guess project root."))))))
(apply orig-fn args))
;; Don't prompt to restart LSP servers while quitting Emacs
(add-hook! 'kill-emacs-hook (setq lsp-restart 'ignore)))
@ -149,10 +148,12 @@ Also logs the resolved project root, if found."
:config
(setq company-lsp-cache-candidates 'auto)) ;; cache candidates for better performance
(use-package! helm-lsp
:when (featurep! :completion helm)
:commands helm-lsp-workspace-symbol helm-lsp-global-workspace-symbol)
(use-package! lsp-ivy
:when (featurep! :completion ivy)
:commands lsp-ivy-workspace-symbol lsp-ivy-global-workspace-symbol)