Skip to content
This repository was archived by the owner on Oct 13, 2021. It is now read-only.

Commit 86bbcb6

Browse files
committed
completion/hover: don't override handler globally
buf_request can take a callback, so let's use that?
1 parent 936bbd1 commit 86bbcb6

File tree

1 file changed

+1
-16
lines changed

1 file changed

+1
-16
lines changed

lua/completion/hover.lua

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -246,13 +246,7 @@ local fancy_floating_markdown = function(contents, opts)
246246
return bufnr, winnr
247247
end
248248

249-
local handler = 'textDocument/hover'
250-
M.default_handler = vim.lsp.handlers[handler]
251-
252249
local function handler_function(_, method, result)
253-
-- if M.winnr ~= nil and api.nvim_win_is_valid(M.winnr) then
254-
-- api.nvim_win_close(M.winnr, true)
255-
-- end
256250
if vim.fn.pumvisible() == 1 then
257251
M.focusable_float(method, function()
258252
if not (result and result.contents) then
@@ -300,20 +294,11 @@ local function handler_function(_, method, result)
300294
end
301295
return bufnr, winnr
302296
end)
303-
else
304-
M.default_handler(_, method, result, _)
305297
end
306298
end
307299

308300
M.autoOpenHoverInPopup = function()
309301
if vim.fn.pumvisible() ~= 1 then return end
310-
for _, client in pairs(vim.lsp.buf_get_clients(0)) do
311-
local default_handler = (client.config.handlers or {})['textDocument/hover'] or vim.lsp.handlers['textDocument/hover']
312-
if default_handler ~= handler_function then
313-
if not client.config.handlers then client.config.handlers = {} end
314-
client.config.handlers['textDocument/hover'] = handler_function
315-
end
316-
end
317302

318303
local bufnr = api.nvim_get_current_buf()
319304
if api.nvim_call_function('pumvisible', {}) == 1 then
@@ -372,7 +357,7 @@ M.autoOpenHoverInPopup = function()
372357
textDocument = vim.lsp.util.make_text_document_params();
373358
position = { line = row; character = col-string.len(item.word); }
374359
}
375-
vim.lsp.buf_request(bufnr, 'textDocument/hover', params)
360+
vim.lsp.buf_request(bufnr, 'textDocument/hover', params, handler_function)
376361
end
377362
manager.textHover = false
378363
end

0 commit comments

Comments
 (0)