Subject: Re: bug#69683: 28.2; eglot overrides imenu without fallback even when unsupported by server

From: Felician Nemeth <[email-masked]>
Date: Sun, 10 Mar 2024 10:46:04 +0100

Phil Hagelberg <[email-masked]> writes:

> When invoking M-x imenu in a buffer with eglot enabled, it uses eglot's
> LSP-aware implementation of imenu. However, not all LSP servers handle
> that functionality. When connected to a server that does not offer this
> functionality, eglot signals an error:
>
>   jsonrpc-error: "request id=11 failed:", (jsonrpc-error-code . -32601), (jsonrpc-error-message . "\"textDocument/documentSymbol\" is not in the request-handlers table"), (jsonrpc-error-data)
>

I'm surprised to see this error message since eglot-imenu starts with
this:

(cl-defun eglot-imenu ()
  (unless (eglot-server-capable :documentSymbolProvider)
    (cl-return-from eglot-imenu))

That is if the LSP server does not have the necessary capability it
doesn't send any jsonrpc messages to the server that would lead to the
error above.  (And it falls back to normal imenu.)

Can you run edebug on eglot-imenu to see what I misunderstand?