Skip to content

Commit

Permalink
Support hover protocol now.
Browse files Browse the repository at this point in the history
  • Loading branch information
manateelazycat committed May 13, 2022
1 parent 65abf31 commit 4fe5db0
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
11 changes: 5 additions & 6 deletions core/fileaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,13 @@ def __init__(self, filepath, project_path, lang_server):
object.__init__(self)

# Build request functions.
for name in ["find_define", "find_references", "prepare_rename", "rename", "completion"]:
for name in ["find_define", "find_references", "prepare_rename", "rename", "completion", "hover"]:
self.build_request_function(name)

# Init.
self.filepath = filepath
self.project_path = project_path
self.request_dict = {}
self.completion_request_list = []
self.find_define_request_list = []
self.find_references_request_list = []
self.prepare_rename_request_list = []
self.rename_request_list = []
self.last_change_file_time = -1
self.last_change_file_before_cursor_text = ""
self.last_change_cursor_time = -1
Expand Down Expand Up @@ -137,6 +132,10 @@ def _do(*args):
args = (request_id, self.filepath, name) + args
getattr(self.lsp_server, "send_{}_request".format(name))(*args)

# Init request list variable.
setattr(self, "{}_request_list".format(name), [])

# Init request method.
setattr(self, name, _do)

def handle_server_response_message(self, request_id, request_type, response_result):
Expand Down
12 changes: 12 additions & 0 deletions core/lspserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,18 @@ def send_rename_request(self, request_id, filepath, type, position, new_name):
"newName": new_name
},
request_id)

def send_hover_request(self, request_id, filepath, type, position):
self.record_request_id(request_id, filepath, type)

self.send_to_request("textDocument/hover",
{
"textDocument": {
"uri": path_to_uri(filepath)
},
"position": position
},
request_id)

def send_shutdown_request(self):
self.shutdown_id = generate_request_id()
Expand Down
4 changes: 4 additions & 0 deletions lsp-bridge.el
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,10 @@ Then LSP-Bridge will start by gdb, please send new issue with `*lsp-bridge*' buf
(pulse-delay lsp-bridge-flash-line-delay))
(pulse-momentary-highlight-region start-pos end-pos 'lsp-bridge-font-lock-flash)))))

(defun lsp-bridge-hover ()
(interactive)
(lsp-bridge-call-async "hover" lsp-bridge-filepath (lsp-bridge--position)))

(defun lsp-bridge-get-pos (buf line column)
(with-current-buffer buf
(save-excursion
Expand Down
2 changes: 1 addition & 1 deletion lsp-bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def __init__(self, args):
self.action_cache_dict = {} # use for contain file action cache

# Build EPC interfaces.
for name in ["change_file", "find_define", "find_references", "prepare_rename", "rename", "change_cursor", "save_file"]:
for name in ["change_file", "find_define", "find_references", "prepare_rename", "rename", "change_cursor", "save_file", "hover"]:
self.build_file_action_function(name)

# Init EPC client port.
Expand Down

0 comments on commit 4fe5db0

Please sign in to comment.