fix(lsp): eglot-ensure advice nooping in some major modes

Due to the nested structure of eglot-server-programs, our advice would
not correctly detect entries for some modes (like javascript modes),
effectively disabling Eglot in those modes.

I've replaced the advice with a solution baked into lsp!, so folks still
have the option of using eglot-ensure directly if they want it activated
unconditionally.

Amend: #7219
This commit is contained in:
Henrik Lissner 2024-08-14 17:56:57 -04:00
parent 88666b1913
commit 173842ccea
No known key found for this signature in database
GPG key ID: B60957CA074D39A3
2 changed files with 4 additions and 10 deletions

View file

@ -4,15 +4,6 @@
:commands eglot eglot-ensure :commands eglot eglot-ensure
:hook (eglot-managed-mode . +lsp-optimization-mode) :hook (eglot-managed-mode . +lsp-optimization-mode)
:init :init
(defadvice! +eglot--ensure-available-mode-a (fn)
"Run `eglot-ensure' if the current mode has support."
:around #'eglot-ensure
(when (alist-get major-mode eglot-server-programs nil nil
(lambda (modes key)
(if (listp modes)
(member key modes)
(eq key modes))))
(funcall fn)))
(setq eglot-sync-connect 1 (setq eglot-sync-connect 1
eglot-autoshutdown t eglot-autoshutdown t
;; NOTE: We disable eglot-auto-display-help-buffer because :select t in ;; NOTE: We disable eglot-auto-display-help-buffer because :select t in

View file

@ -5,6 +5,9 @@
"Dispatch to call the currently used lsp client entrypoint" "Dispatch to call the currently used lsp client entrypoint"
(interactive) (interactive)
(if (modulep! +eglot) (if (modulep! +eglot)
(when (require 'eglot nil t)
(if (eglot--lookup-mode major-mode)
(eglot-ensure) (eglot-ensure)
(eglot--message "No client defined for %s" major-mode)))
(unless (bound-and-true-p lsp-mode) (unless (bound-and-true-p lsp-mode)
(lsp-deferred)))) (lsp-deferred))))