Add +lsp-prompt-to-install-server option

If nil, LSP will quietly fail if no LSP server is available instead of
pestering the user to install a server.
This commit is contained in:
Henrik Lissner 2021-02-05 21:53:06 -05:00
parent d0b6cef8a5
commit 95a603733a

View file

@ -4,6 +4,9 @@
"The backends to prepend to `company-backends' in `lsp-mode' buffers.
Can be a list of backends; accepts any value `company-backends' accepts.")
(defvar +lsp-prompt-to-install-server t
"If non-nil, prompt to install a server if no server is present.")
;;
;;; Packages
@ -108,7 +111,18 @@ server getting expensively restarted when reverting buffers."
(let ((lsp-restart 'ignore))
(funcall orig-fn))
(+lsp-optimization-mode -1))))
lsp--cur-workspace)))))
lsp--cur-workspace))))
(defadvice! +lsp-dont-prompt-to-install-servers-maybe-a (orig-fn &rest args)
:around #'lsp
(lsp--require-packages)
(when (buffer-file-name)
(if (or (lsp--filter-clients
(-andfn #'lsp--matching-clients?
#'lsp--server-binary-present?))
+lsp-prompt-to-install-server)
(apply orig-fn args)
(lsp--info "No language server available for %S" major-mode)))))
(use-package! lsp-ui