3

I have configured lsp-mode as follows:

(use-package lsp-mode
  :straight t
  :init (setq lsp-keymap-prefix "C-c l")
  :hook ((python-mode . lsp))
  :commands lsp)

I am also using desktop-save-mode to restore my editing state upon restart. When I have several projects open and quit Emacs, the restart takes a long time as it starts each lsp server. Is there a way to start each server only when I run an lsp-related command in the buffer?

3

How about:

(use-package lsp-mode
  :straight t
  :init (setq lsp-keymap-prefix "C-c l")
  :hook (python-mode . lsp-deferred))

The doc for lsp-deferred:

Signature
(lsp-deferred)

Documentation
Entry point that defers server startup until buffer is visible.

lsp-deferred will wait until the buffer is visible before invoking lsp.
This avoids overloading the server with many files when starting Emacs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.