tools/lsp: defer lsp init until buffer is visible
This commit is contained in:
parent
f9e25f95a8
commit
2d2413d293
2 changed files with 30 additions and 32 deletions
|
@ -1,31 +1,4 @@
|
||||||
;;; feature/lsp/autoload.el -*- lexical-binding: t; -*-
|
;;; feature/lsp/autoload.el -*- lexical-binding: t; -*-
|
||||||
|
|
||||||
;;;###autodef
|
;;;###autodef
|
||||||
(defun lsp! (&optional arg)
|
(defalias 'lsp! #'lsp-deferred)
|
||||||
"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:
|
|
||||||
|
|
||||||
+ `+lsp-init-company-h' (on `lsp-mode-hook')
|
|
||||||
+ `+lsp-init-ui-flycheck-or-flymake-h' (on `lsp-ui-mode-hook')"
|
|
||||||
(if (bound-and-true-p lsp-mode)
|
|
||||||
t
|
|
||||||
(require 'lsp-mode)
|
|
||||||
(when lsp-auto-configure
|
|
||||||
(require 'lsp-clients))
|
|
||||||
(when (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)
|
|
||||||
(lsp--info
|
|
||||||
"Connected to %s."
|
|
||||||
(apply
|
|
||||||
#'concat (mapcar
|
|
||||||
(lambda (it) (format "[%s]" (lsp--workspace-print it)))
|
|
||||||
lsp--buffer-workspaces)))))))
|
|
||||||
|
|
|
@ -20,10 +20,35 @@ This can be a single company backend or a list thereof. It can be anything
|
||||||
:definition 'lsp-find-definition
|
:definition 'lsp-find-definition
|
||||||
:references 'lsp-find-references)
|
:references 'lsp-find-references)
|
||||||
|
|
||||||
;; The original `lsp' initializes too much, too quickly. Things like flycheck,
|
(defadvice! +lsp-init-a (&optional arg)
|
||||||
;; company, and yasnippet. Doom's modules already handle these just fine, so
|
:override #'lsp
|
||||||
;; leave it to us.
|
"Enable `lsp-mode' in the current buffer.
|
||||||
(advice-add #'lsp :override #'lsp!)
|
|
||||||
|
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:
|
||||||
|
|
||||||
|
+ `+lsp-init-company-h' (on `lsp-mode-hook')
|
||||||
|
+ `+lsp-init-ui-flycheck-or-flymake-h' (on `lsp-ui-mode-hook')"
|
||||||
|
(interactive "P")
|
||||||
|
(if (bound-and-true-p lsp-mode) t
|
||||||
|
(require 'lsp-mode)
|
||||||
|
(when lsp-auto-configure
|
||||||
|
(require 'lsp-clients))
|
||||||
|
(when (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)
|
||||||
|
(lsp--info
|
||||||
|
"Connected to %s."
|
||||||
|
(apply
|
||||||
|
#'concat (mapcar
|
||||||
|
(lambda (it) (format "[%s]" (lsp--workspace-print it)))
|
||||||
|
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)))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue