tools/lsp: start lsp server unconditionally

Part 2 of f6d3ee588, in order for server restarting to work, since
shutting down the server doesn't turn off lsp-mode.
This commit is contained in:
Henrik Lissner 2019-11-02 15:50:26 -04:00
parent f6d3ee5889
commit 16a17ad970
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -74,27 +74,26 @@ been moved out to their respective modules, or these hooks:
Also logs the resolved project root, if found." Also logs the resolved project root, if found."
:override #'lsp :override #'lsp
(interactive "P") (interactive "P")
(if (bound-and-true-p lsp-mode) t (require 'lsp-mode)
(require 'lsp-mode) (when lsp-auto-configure
(when lsp-auto-configure (require 'lsp-clients))
(require 'lsp-clients)) (and (buffer-file-name)
(and (buffer-file-name) (setq-local
(setq-local lsp--buffer-workspaces
lsp--buffer-workspaces (or (lsp--try-open-in-library-workspace)
(or (lsp--try-open-in-library-workspace) (lsp--try-project-root-workspaces
(lsp--try-project-root-workspaces (equal arg '(4))
(equal arg '(4)) (and arg (not (equal arg 1))))))
(and arg (not (equal arg 1)))))) (prog1 (lsp-mode 1)
(prog1 (lsp-mode 1) ;; Announce what project root we're using, for diagnostic purposes
;; Announce what project root we're using, for diagnostic purposes (if-let (root (lsp--calculate-root (lsp-session) (buffer-file-name)))
(if-let (root (lsp--calculate-root (lsp-session) (buffer-file-name))) (lsp--info "Guessed project root is %s" (abbreviate-file-name root))
(lsp--info "Guessed project root is %s" (abbreviate-file-name root)) (lsp--info "Could not guess project root."))
(lsp--info "Could not guess project root.")) (lsp--info "Connected to %s."
(lsp--info "Connected to %s." (apply #'concat
(apply #'concat (mapcar
(mapcar (lambda (it) (format "[%s]" (lsp--workspace-print it)))
(lambda (it) (format "[%s]" (lsp--workspace-print it))) lsp--buffer-workspaces))))))
lsp--buffer-workspaces)))))))
;; Don't prompt to restart LSP servers while quitting Emacs ;; Don't prompt to restart LSP servers while quitting Emacs
(add-hook! 'kill-emacs-hook (setq lsp-restart 'ignore))) (add-hook! 'kill-emacs-hook (setq lsp-restart 'ignore)))