Ensure eglot does not take full control of Xref

Eglot by default will take full control of xref and make the
xref-backend-functions (eglot-xref-backend t) .

To have dumb-jump as backup if eglot would fail, instruct eglot to
stay out of Xref and add/remove eglot xref backend manually.
This commit is contained in:
Laurens Miers 2024-09-19 22:44:41 +02:00
parent 2c29e77132
commit 0482e48c7f

View file

@ -486,17 +486,15 @@ Install and wait for hydra to be available since we are using it in this init.el
#+BEGIN_SRC emacs-lisp
(use-package eglot
:ensure t
:defer t
;; This doesn't work for some reason, workaround below
;;:hook (prog-mode . eglot-ensure)
;; :config
;; (add-hook 'prog-mode-hook 'eglot-ensure)
)
#+END_SRC
Workaround to enable eglot in all programming modes:
#+BEGIN_SRC emacs-lisp
(setq eglot-stay-out-of '(xref))
(add-hook 'prog-mode-hook 'eglot-ensure)
(add-hook 'eglot-managed-mode-hook (lambda ()
(if (eglot-managed-p)
(add-hook 'xref-backend-functions 'eglot-xref-backend)
(remove-hook 'xref-backend-functions 'eglot-xref-backend)
)))
#+END_SRC
** Yasnippet