Subject: Re: bug#65518: 30.0.50; [FR Eglot] Completions over all workspace symbols

From: Gerd Möllmann <[email-masked]>
Date: Sat, 26 Aug 2023 07:09:30 +0200

João Távora <[email-masked]> writes:

> Gerd Möllmann <[email-masked]> writes:
>
>> I'm in a C buffer with Eglot running, and I want to go to the definition
>> of something whose name I know, but point is not on an identifier naming
>> that thing.  For instance, I want to go the definition of Lisp_Package
>> (in an obsure branch having a struct Lisp_Package), while point is
>> somewhere.
>
>>
>> C-u M-. offers some completions, but Lisp_Package is not among them.
>> Not using a completion and entering Lisp_Package works.
>
> Like I explained in bug#65517 (which see), this too is based on the
> 'workspace/symbol' request.  You can check your Eglot events buffer (M-x
> eglot-events-buffer) around the time you press C-u M-. to get a feel of
> how the server responds to these queries.
>
> You'll see Eglot sends the widest possible 'query' to the LSP server
> which returns a limited number of names (clangd caps at exactly 100 by
> default).  In large projects it's unlikely the symbol you're looking for
> is there, but as you type more text into the prompt, further
> 'workspace/symbol' requests are made.
>
> Note that, similarly to many other LSP situations, Eglot and Emacs has
> no control over _how_ the server interprets the 'query' string, so there
> is no control over the "completion style" and your setting of
> 'completion-style' has no effect here. The clangd LSP server in
> particular seems to use a somewhat "flex" or "fuzzy" completion style.
>
> You didn't specify exactly how you entered input into your search box,
> and what completion package, if any, you are using.  So, whereas in
> bug#65517 it was simple to understand the root cause of the observed
> behavior, in this particular case, I'm afraid I'm going to have to refer
> you to the usual checklist on making reproducible bug reports for Eglot:
>
>   https://joaotavora.github.io/eglot/#Troubleshooting-Eglot
>
> Here, for your specific example, I'm guessing the project is Emacs
> itself (checked out in your CL packages branch).  I'm also guessing
> you're using the `clangd` server and some of compile_commands.json.
>
> Confirming this data and specifying versions etc should be enough for me
> to reproduce the problem exactly as it appeared to you.  I'm also
> guessing (or at least hoping), you don't use complicated third party
> completion packages and everything can be experimented with via Emacs
> -Q.
>
> For reference, C-u M-. works fairly well here in my projects when used
> with clangd 15.0.7 and the compile_commands.json file generated by the
> CMake system.  I don't yet fully understand how clangd's sorting
> heuristics and completion pattern matching work, but I seem to
> eventually reach the name I want.

We are miscommunicating.  This is not a bug report, it's a feature
request. Referring me to a description of how to produce reproducible
bug reports I therefore find odd.

As I mentioned, lsp-mode offers the functionality, that I'd like to see in
Eglot.  I don't know how it does it, and I don't care, really.