No-op (lsp) if already enabled #3390

`lsp-deferred` calls `lsp` and `lsp` seems to do something expensive
whether or not lsp-mode is already active. Over TRAMP, this is much too
expensive, so we no-op lsp-deferred if lsp-mode is already active.
This commit is contained in:
Henrik Lissner 2020-08-02 16:27:09 -04:00
parent b08f9c607d
commit 7784c0b6e9
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
2 changed files with 3 additions and 2 deletions

View file

@ -90,7 +90,7 @@ This also logs the resolved project root, if found, so we know where we are."
;; GC-induced slowdowns/freezes. ;; GC-induced slowdowns/freezes.
(setq-local gcmh-high-cons-threshold (* 2 gcmh-high-cons-threshold)) (setq-local gcmh-high-cons-threshold (* 2 gcmh-high-cons-threshold))
(prog1 (lsp-mode 1) (prog1 (lsp-mode 1)
(setq-local lsp-buffer-uri (lsp--buffer-uri)) (setq lsp-buffer-uri (lsp--buffer-uri))
;; 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))

View file

@ -6,4 +6,5 @@
(interactive) (interactive)
(if (featurep! +eglot) (if (featurep! +eglot)
(eglot-ensure) (eglot-ensure)
(lsp-deferred))) (unless (bound-and-true-p lsp-mode)
(lsp-deferred))))