Subject: Re: bug#69657: Missing imenu entries with eglot

From: João Távora <[email-masked]>
Date: Sun, 10 Mar 2024 19:33:58 +0000

On Sun, Mar 10, 2024 at 7:22 PM Sebastian Poeplau
<[email-masked]> wrote:

> Here's the return value of eglot-imenu with pylsp:
>
> ((#1="Class"
>      (#("Foo" 0 3 (breadcrumb-kind #1# breadcrumb-region (1 . 44))) . 1))
>  (#2="Method"
>      ("Foo" (#("bar" 0 3 (breadcrumb-kind #2# breadcrumb-region (16 . 44))) . 16))))

> For completeness, this is pylsp's response to
> textDocument/documentSymbol:

See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_documentSymbol

pylsp does this because it is old, it uses SymbolInformation.

clangd and most other servers use DocumentSymbol[] which is not
only much more powerful and logical for represting a file's AST but
also doesn't lend itself well to that structure of categorization, which
is rather useless except for the fact that it makes leaves out of AST
non-leaves.

The problems are in Imenu.

You should rather lobby for a better imenu structure (which will be
hard to  do fully  backward compatibly will all existing UIs -- except if
you use the string properties trick that Eglot/breadcrumb use as
I explained)  You could also lobby for a brand new imenu replacement
in Emacs.

João