Has anyone setup LSP mode to use https://github.com/minad/marginalia annotations so that the completion list shows docstrings and function arguments? Basically, I want all of my LSP completions to be as detailed and rich as the built-in Emacs`describe-function`
Raised the question of returning structured data on the https://github.com/clojure-lsp/clojure-lsp/issues/1929.
This is my first time really digging into lsp stuff too. I've set lsp-log-io to t and see that I'm getting the docstring back as markdown:
[Trace - 03:59:20 PM] Received response 'completionItem/resolve - (394)' in 18ms.
Result: {
"label": "foo",
"kind": 3,
"score": 14,
"documentation": {
"kind": "markdown",
"value": "clojure\ncom.keminglabs.windowtron.core/foo [a]\n\n\nmy docstring\n\n----\n\n*[/Users/dev/work/windowtron/src-clj/src/com/keminglabs/windowtron/core.cljc](file:///Users/dev/work/windowtron/src-clj/src/com/keminglabs/windowtron/core.cljc)*"
}
}
but surprisingly it doesn't seem like the lsp server is reporting any info about the arguments in a structured way.I know right? My personal pet pieve. I have a command to get a fully qualified name at point, and this is the BS I have to go through to extract it (excerpt):
((lsp--capability :hoverProvider)
(when-let* ((cnt (-some->
"textDocument/hover"
(lsp--make-request
(lsp--text-document-position-params))
(lsp--send-request)
(lsp:hover-contents)))
;; I think with native-comp it comes as a hash,
;; otherwise as cons
(s (or (plist-get cnt :value)
(gethash "value" cnt))))
(string-match "clojure\n\\([[graph]]+/[[graph]]+\\)" s)
(string-trim (match-string 1 s))))```
Here's the entire command:
https://github.com/agzam/.doom.d/blob/main/modules/custom/clojure/autoload/cider.el#L88I dug a bit further into this and while clojure-lsp has all of the data structured on its side, it shoves everything into strings or markdown strings as per the https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#completionItem. Short of forking clojure-lsp to just throw a ton of extra data into the json it returns (which would be in the spirit of Clojure) I'm going to have a go at extracting it from the returned markdown on the emacs side. let's see how this goes...