Skip to content

Commit

Permalink
tweak(lsp): update to the new auto-enable convention
Browse files Browse the repository at this point in the history
  • Loading branch information
abougouffa committed Dec 23, 2023
1 parent 69b20ed commit 6856b09
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion core/me-lib.el
Original file line number Diff line number Diff line change
Expand Up @@ -1201,7 +1201,8 @@ be deleted.
"Auto-enable Eglot in configured modes in `+eglot-auto-enable-modes'."
(interactive)
(dolist (mode +eglot-auto-enable-modes)
(add-hook 'after-change-major-mode-hook #'+eglot--ensure-maybe-h)))
(add-hook 'after-change-major-mode-hook #'+eglot--ensure-maybe-h)
(remove-hook 'after-change-major-mode-hook #'+lsp--ensure-maybe-h)))

(defun +eglot-use-on-all-supported-modes (mode-list)
"Add all modes in MODE-LIST to `+eglot-auto-enable-modes'."
Expand Down
9 changes: 6 additions & 3 deletions modules/me-lsp.el
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,16 @@
"Modes for which LSP-mode can be automatically enabled by `+lsp-auto-enable'."
:group 'minemacs-prog
:type '(repeat symbol))
(defun +lsp--ensure-maybe-h ()
"Maybe auto start LSP if the current mode is in `+lsp-auto-enable-modes'."
(when (memq major-mode +lsp-auto-enable-modes)
(lsp-deferred)))
(defun +lsp-auto-enable ()
"Auto-enable LSP-mode in configured modes in `+lsp-auto-enable-modes'."
(interactive)
(dolist (mode +lsp-auto-enable-modes)
(let ((hook (intern (format "%s-hook" mode))))
(add-hook hook #'lsp-deferred)
(remove-hook hook #'eglot-ensure))))
(add-hook 'after-change-major-mode-hook #'+lsp--ensure-maybe-h)
(remove-hook 'after-change-major-mode-hook #'+eglot--ensure-maybe-h)))
:config
(+map! :keymaps 'lsp-mode-map
:infix "c"
Expand Down

0 comments on commit 6856b09

Please sign in to comment.