reddit / emacs

Show signature help as hover documentation with lsp-ui

regexPattern ยท 2022-06-10 22:15
Is there any way to show the LSP result for the `textDocument/signatureHelp` message as a fallback for the `textDocument/hover` message result using lsp-ui? For example: I have a function that is properly documented such as the following: /** * This function is documented. */ const myFunction = (a: number, b: number) => { return a + b; } When `lsp-ui-doc-show` is called it shows the documentation for that function as expected: [Result of calling lsp-ui-doc-show.](https://preview.redd.it/taaiewj3av491.png?width=428&format=png&auto=webp&s=f91b72b494569a9b1c910d2218f0d6061895e53b) When the function has no documentation comments, it shows nothing, as expected as well. What I want is to show at least the function signature on an lsp-ui popup when `lsp-ui-doc-show` is called and there's no documentation. I'm new to Emacs coming from Neovim, and there it seems like the function signature is returned as fallback for the LSP `textDocument/hover` when there is no documentation: [Results of the textDocument\/hover action for a function without documentation.](https://preview.redd.it/a7lwl7d29v491.png?width=579&format=png&auto=webp&s=16aa2ad330a94afecd9457386df1e2f1006c675b) From what I undestand this information is the result of calling `textDocument/signatureHelp` of the LSP, because this is the same that is shown as signature when lsp-eldoc is active, and after reading the code, it seems like `lsp-ui-doc-show` only calls `textDocument/hover`. ​ [This is en emacs, using eldoc when I hover over the function without documentation.](https://preview.redd.it/1aqgocms9v491.png?width=475&format=png&auto=webp&s=bfd02b689fb9fae05711e569d4d8599dd3fa518b) At first I thought there might be a way to pipe the `textDocument/signatureHelp` to the same window that renders when calling that lsp-ui function, but I seems like they implemented a parsing function (fairly complex for my knowing of lisp at least) that only works with the hover action results. Does anyone know what could be done in this case? Maybe a package, an lsp-ui function I'm missing, or a way to get the `textDocument/signatureHelp` parse it myself and then pipe it to lsp-ui doc's window in a custom function so it works as a fallback in response to a unique custom function that replaces `lsp-ui-doc-show`? Thanks in advance. Note: All of this is using the typescript-language-server with lsp-mode and lsp-ui of course. It's the server called `ts-ls`.