Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lsp-mode doesn't show textDocument/hover in pop-up when response is MarkedString[] #4626

Closed
3 tasks done
niontrix opened this issue Nov 27, 2024 · 3 comments
Closed
3 tasks done
Labels

Comments

@niontrix
Copy link
Contributor

niontrix commented Nov 27, 2024

Thank you for the bug report

  • I am using the latest version of lsp-mode related packages.
  • I checked FAQ and Troubleshooting sections
  • You may also try reproduce the issue using clean environment using the following command: M-x lsp-start-plain

Bug description

When a language server provides a textDocument/hover response with a single string as content like this:

[Trace - 12:42:18 ] Received response 'textDocument/hover - (15)' in 4ms.
Result: {
  "contents": "File: file:///home/somuser/diy-language-server/README.md, Characters: 302"
}

then the documentation is shown as a pop-up.
When a language server provides a textDocument/hover response with as MarkedString[] like this:

[Trace - 01:04:47 ] Received response 'textDocument/hover - (8)' in 10ms.
Result: {
  "contents": [
    {
      "value": "File: file:///home/someuser/diy-language-server/README.md, Characters: 302",
      "language": "markdown"
    }
  ]
}

then the documentation is shown only in the minibuffer.

Steps to reproduce

  • Use for example gopls as a language server and open a Go file. gopls sends its hover responses as single strings.
  • Use nimlangserver and open a Nim file. nimlangserver sends its hover responses as an array of MarkedString

Expected behavior

lsp-mode should show hover responses using MarkedString[] as content in a pop-up.

Which Language Server did you use?

I used nimlangserver v1.6.0.

OS

Linux

Error callstack

No response

Anything else?

Also could you please explain how displaying the content of a textDocument/hover response works when being displayed as a pop-up as well as in the minibuffer, so I can get a better understanding of how lsp-mode works and maybe in the future contribute my own PR for issues like this?

@niontrix niontrix added the bug label Nov 27, 2024
@kiennq
Copy link
Member

kiennq commented Nov 28, 2024

Also could you please explain how displaying the content of a textDocument/hover response works when being displayed as a pop-up as well as in the minibuffer, so I can get a better understanding of how lsp-mode works and maybe in the future contribute my own PR for issues like this?

I don't think lsp-mode has the popup for showing the hover. Are you using lsp-ui for that?
For how the textDocument/hover works in lsp-mode, you can search inside lsp-mode.el, there're 3 places (2 for describe thing at point, 1 for eldoc) that request that, and they will eventually call lsp--render-on-hover-content to display the content.

@niontrix
Copy link
Contributor Author

Yes, that is how far I understood it, but I couldn't really find how the pop-up is displayed in the end. But I think you're right this might potentially be a problem with lsp-ui. I'll take a look and maybe open a ticket over there.
Thanks! 👍

@niontrix
Copy link
Contributor Author

niontrix commented Nov 28, 2024

I created the following ticket over on lsp-ui - just for reference: #783

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants