Skip to content

Possibility to send range in a hover request #4014

Open
@kurnevsky

Description

@kurnevsky

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions