Description
Would y'all be open to a PR that populates the optional data field of the LSP completionItem with a map of more structured information?
E.g., for a function it would include the symbol, fully qualified symbol, docstring, arglist, etc.
This would allow clients to display more structured information.
I started investigating this when I noticed that the Emacs completions were quite bare for lsp-mode Clojure:
compared to the built-in Emacs describe function:
(These screenshots are using the Vertico and Marginalia Emacs packages.)
I would love for the completion to actually search for matches in docstrings too, though that would likely be a more involved change.
(I'd probably build an n-gram index using roaring bitmaps.)
Anyway, just wanted to float the idea before I started working on anything.
I totally understand if this would be out of scope for the project and more appropriate for a fork / standalone thing.
Clojure LSP is really cool and I will continue to use it either way --- thanks for all the great work!


Activity
ericdallo commentedon Jan 13, 2025
@lynaghk the data field is used to trafic information server -> client so when client resolves the item in a next request (completionItem/resolve), send again that field to resolve extra things like docs.
Concerns I see:
datafield, this may affect performance, as the data field is returned for all items, if you are completing and receiving 100 items, you are saying you are adding a lot more info for each item, that's why completionItem/resolve exists, to resolve a single item after user hovered over that itemlynaghk commentedon Jan 16, 2025
Thanks @ericdallo for the feedback and pointers. I took a closer look at
completionItem/resolveand it does seem like lsp-mode in emacs is calling that automatically when populating the completion list and it's getting the documentation back formatted as markdown:Would it be appropriate to add a machine-parsable data field on this response? Then the editor could format additional information in the popup (docstring, arglists, etc.)
ericdallo commentedon Jan 16, 2025
@kiennq any idea why lsp-mode doesn't call resolveItem automatically like other editors?
kiennq commentedon Jan 17, 2025
The
resolveItemis called when:I've tried to preemptively call the
resolveItemon item annotation before but unfortunately it flooded the language server with multiple requests (around a page of candidates) and make thing slow down for the language server so @wyuenho reverted it in emacs-lsp/lsp-mode#4625wyuenho commentedon Jan 17, 2025
@ericdallo
What do you mean by calling resolveItem automatically and which editor does this?
ericdallo commentedon Jan 17, 2025
@wyuenho, vscode and zed that I'm aware of, they resolve the item as soon it's hovered in the completion popup (which makes sense to me as they show more info in the completion for the hovered item)
wyuenho commentedon Jan 17, 2025
That's the Show More/Less feature from VSCode that requires completion frontend cooperation in Emacs. No completion frontend in Emacs supports that at the moment but emacs-lsp/lsp-mode#4625 laid the groundwork for that. @dgutov will need to take advantage of
:company-docsigin the completion menu, and corfu needs to do the same.For now, you can give https://github.com/wyuenho/emacs-corfu-pixel-perfect a try. The README is very much outdated but the package works quite well, I'm using it daily.
wyuenho commentedon Jan 17, 2025
As a side node, I think clojure-lsp's response to
textDocument/completionis very much lacking. It doesn't supportlabelDetails,detailis only used for FQN. Completion is also wrong or incomplete, or return too much or different things when backspacing. There's no support forsortText, orfilterText,textDocument/documentSymbolis also incredibly slow. If you are looking for opportunities to improve performance and the experience for clojure-lsp users, I think the server leaves a lot to be desired.If clojure-lsp supports
detailorlabelDetailsintextDocument/completionproperly, this issue will be moot.ericdallo commentedon Jan 17, 2025
I don't think completion is bad currently. We have already iterated multiple times to improve performance, and there are no complaints about performance at the moment.
I need to check what
labelDetailsis different thandetailor the other fields, but I'm not aware of a bad UX in any editor regarding completion besides this issue