Skip to content

Commit

Permalink
Add custom desktop minor mode handler for lsp-deferred
Browse files Browse the repository at this point in the history
Use lsp-deferred instead of lsp-mode even in the case that lsp-mode
appears in the list of minor modes for a file in a user's desktop file
by adding the buffer-local variable lsp--buffer-deferred (which tracks
whether a given buffer was started using lsp-deferred) to the variable
desktop-locals-to-save so that it is persisted in a user's desktop
file, and adding a custom handler to desktop-minor-mode-handlers which
uses this persisted variable to determine whether to use lsp-deferred
of lsp-mode when re-opening a file from the desktop file.
  • Loading branch information
LaurenceWarne committed Feb 26, 2023
1 parent b45dea4 commit d2d58d8
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lsp-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -9124,6 +9124,14 @@ This avoids overloading the server with many files when starting Emacs."
(unless (lsp--init-if-visible)
(add-hook 'window-configuration-change-hook #'lsp--init-if-visible nil t))))))))

(with-eval-after-load 'desktop
(add-to-list 'desktop-locals-to-save 'lsp--buffer-deferred)
(add-to-list 'desktop-minor-mode-handlers
'(lsp-mode . (lambda (desktop-buffer-locals)
(if (alist-get 'lsp--buffer-deferred desktop-buffer-locals)
(lsp-deferred)
(lsp-mode))))))



(defvar lsp-file-truename-cache (ht))
Expand Down

0 comments on commit d2d58d8

Please sign in to comment.