Skip to content

Commit

Permalink
support ranger hover (for rust-analyzer now)
Browse files Browse the repository at this point in the history
  • Loading branch information
fuyu0425 committed Oct 24, 2024
1 parent 4ddd115 commit 42f107b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
11 changes: 9 additions & 2 deletions core/handler/hover.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,16 @@ class Hover(Handler):
name = "hover"
method = "textDocument/hover"

def process_request(self, position, show_style) -> dict:
def process_request(self, start, end, show_style) -> dict:
lsp_server_name = self.file_action.get_match_lsp_servers("hover")[0].server_info['name']
self.show_style = show_style
return dict(position=position)

# rust-analyzer support range hover (not in LSP standard)
if start == end or lsp_server_name != "rust-analyzer":
return dict(position=start)
else:
range = {"start": start, "end": end}
return dict(position=range)

def parse_hover_contents(self, contents, render_strings):
if isinstance(contents, str):
Expand Down
8 changes: 6 additions & 2 deletions lsp-bridge.el
Original file line number Diff line number Diff line change
Expand Up @@ -2071,11 +2071,15 @@ Off by default."

(defun lsp-bridge-show-documentation ()
(interactive)
(lsp-bridge-call-file-api "hover" (lsp-bridge--position) "buffer"))
(let* ((start (lsp-bridge--point-position (if (region-active-p) (region-beginning) (point))))
(end (lsp-bridge--point-position (if (region-active-p) (region-end) (point)))))
(lsp-bridge-call-file-api "hover" start end "show")))

(defun lsp-bridge-popup-documentation ()
(interactive)
(lsp-bridge-call-file-api "hover" (lsp-bridge--position) "popup"))
(let* ((start (lsp-bridge--point-position (if (region-active-p) (region-beginning) (point))))
(end (lsp-bridge--point-position (if (region-active-p) (region-end) (point)))))
(lsp-bridge-call-file-api "hover" start end "popup")))

(defun lsp-bridge-signature-help-fetch ()
(interactive)
Expand Down

0 comments on commit 42f107b

Please sign in to comment.