Eglot: set imenu-create-index-function without advice

See https://github.com/joaotavora/eglot/issues/1569.

* lisp/progmodes/eglot.el (eglot--managed-mode): Stomp on
imenu-create-index-function conditionally.
(eglot-imenu): Don't check eglot-server-capable here.

* etc/EGLOT-NEWS: Mention change.
This commit is contained in:
João Távora 2026-01-19 23:57:59 +00:00
parent d3548aea96
commit f643ad53c7
2 changed files with 8 additions and 5 deletions

View file

@ -45,6 +45,11 @@ thinks responses to inflight requests are no longer useful. The current
2026 LSP landscape (especially gopls and ocamllsp) suggests this is
beneficial and helps servers avoid costly useless work.
** Imenu setup no longer uses advice (github#1569)
Eglot now sets 'imenu-create-index-function' directly without using
advice, making the integration cleaner and more predictable.
* Changes in Eglot 1.21 (11/1/2026)

View file

@ -2364,9 +2364,9 @@ the previous reports for TOKEN.")
(eglot--setq-saving company-tooltip-align-annotations t)
(eglot--setq-saving eldoc-documentation-strategy
#'eldoc-documentation-compose)
(unless (eglot--stay-out-of-p 'imenu)
(add-function :before-until (local 'imenu-create-index-function)
#'eglot-imenu))
(unless (or (eglot--stay-out-of-p 'imenu)
(not (eglot-server-capable :documentSymbolProvider)))
(eglot--setq-saving imenu-create-index-function #'eglot-imenu))
(unless (eglot--stay-out-of-p 'flymake) (flymake-mode 1))
(unless (eglot--stay-out-of-p 'eldoc)
(dolist (f (list #'eglot-signature-eldoc-function
@ -4222,8 +4222,6 @@ for which LSP on-type-formatting should be requested."
(cl-defun eglot-imenu ()
"Eglot's `imenu-create-index-function'.
Returns a list as described in docstring of `imenu--index-alist'."
(unless (eglot-server-capable :documentSymbolProvider)
(cl-return-from eglot-imenu))
(let* ((res (eglot--request (eglot--current-server-or-lose)
:textDocument/documentSymbol
`(:textDocument