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

Possibility to send range in a hover request #4014

Open
kurnevsky opened this issue Apr 1, 2023 · 2 comments
Open

Possibility to send range in a hover request #4014

kurnevsky opened this issue Apr 1, 2023 · 2 comments

Comments

@kurnevsky
Copy link
Member

kurnevsky commented Apr 1, 2023

There is an open issue in lsp protocol to allow to send ranges in hover requests. It's already implemented in some lsp servers, e.g rust-analyzer and metals. However because it's not standardized the implementation is different - metals adds an additional optional field while rust-analyzer accepts range in the position field. For metals it can be implemented in a hacky way like:

(defun lsp--text-document-position-params (&optional identifier position range)
  "Make TextDocumentPositionParams for the current point in the current document.
If IDENTIFIER, POSITION and RANGE are non-nil, they will be used as the document
identifier and the position respectively."
  (list :textDocument (or identifier (lsp--text-document-identifier))
    :position (or position (lsp--cur-position))
    :range (or range (when (use-region-p) (lsp--region-to-range (region-beginning) (region-end))))))

This is useful to infer type of the selection.

@kurnevsky
Copy link
Member Author

kurnevsky commented Apr 1, 2023

Metals also sets capabilities.experimental.rangeHoverProvider: true in the initialize response which can be used (while rust one is capabilities.experimental.hoverRange).

@matklad
Copy link
Contributor

matklad commented Oct 12, 2023

I'd be open to changing rust-analyzer implementation to match that of metals!

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

No branches or pull requests

2 participants