Subject: bug#69657: Missing imenu entries with eglot

From: Sebastian Poeplau <[email-masked]>
Date: Fri, 08 Mar 2024 23:28:26 +0100

> How do you invoke imenu?

I did M-x imenu, although I should add that I normally use
consult-imenu, which presents a flattened menu. That's also what I wrote
the patch for.

> If I type M-x imenu-add-menubar-index RET, then I cannot select "Foo"
> as you wrote above. However, if I apply the patch, the menu looks
> exactly the same.

Indeed, it seems that for regular imenu the patch doesn't make a
difference (presumably because both the category and the symbol have the
same name). I had tested that the entry for "Foo" is absent, but I guess
i should have verified that it shows up with the patch. In any case, for
users of consult-imenu (and possibly others) there's a benefit, also in
terms of consistency with language servers that use SymbolInformation.

> On the other hand, the patch seems to ruin breadcrumb-mode: putting
> the point after "{}", the breadcrumb header line shows: "dir/test.cpp:
> Class > Foo" instead of the original "dir/test.cpp: Class > Foo >
> bar".

If you move point _after_ "{}", you're outside of method "bar", aren't
you? Doesn't that mean the breadcrumb header is correct now and was
wrong before?

> $ clangd --version
> Debian clangd version 14.0.6
> Features: linux+grpc

I tested with clangd 15 from the Ubuntu repositories and clangd 17 from
the repositories maintained by the LLVM project (for Ubuntu and Debian).
But I don't think this is a matter of clangd versions; for the record,
this is the textDocument/documentSymbol response I'm getting for the
example in my original message:

{
  "id": 5,
  "jsonrpc": "2.0",
  "result": [
    {
      "children": [
        {
          "detail": "void ()",
          "kind": 6,
          "name": "bar",
          "range": {
            "end": {
              "character": 15,
              "line": 1
            },
            "start": {
              "character": 2,
              "line": 1
            }
          },
          "selectionRange": {
            "end": {
              "character": 10,
              "line": 1
            },
            "start": {
              "character": 7,
              "line": 1
            }
          }
        }
      ],
      "detail": "class",
      "kind": 5,
      "name": "Foo",
      "range": {
        "end": {
          "character": 1,
          "line": 2
        },
        "start": {
          "character": 0,
          "line": 0
        }
      },
      "selectionRange": {
        "end": {
          "character": 9,
          "line": 0
        },
        "start": {
          "character": 6,
          "line": 0
        }
      }
    }
  ]
}