Skip to content
This repository has been archived by the owner on Aug 11, 2024. It is now read-only.

Commit

Permalink
remove backward compatibility (#10)
Browse files Browse the repository at this point in the history
#### Purpose

Fix hover action, closes #7.
Thanks to #7 (comment)
  • Loading branch information
kkharji authored Oct 3, 2021
1 parent bafeddf commit 373bc03
Showing 1 changed file with 20 additions and 48 deletions.
68 changes: 20 additions & 48 deletions lua/lspsaga/hover.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,56 +16,28 @@ local function focusable_float(unique_name, fn)
end
end

hover.handler = (function()
--- TODO: remove nvim-5.1 is released
if vim.fn.has "nvim-0.5" == 1 then
return function(_, method, result)
focusable_float(method, function()
if not (result and result.contents) then
return
end
local markdown_lines = lsp.util.convert_input_to_markdown_lines(result.contents)
markdown_lines = lsp.util.trim_empty_lines(markdown_lines)
if vim.tbl_isempty(markdown_lines) then
return
end
window.nvim_win_try_close()
local bufnr, winid = window.fancy_floating_markdown(markdown_lines)

lsp.util.close_preview_autocmd({
"CursorMoved",
"BufHidden",
"BufLeave",
"InsertCharPre",
}, winid)
return bufnr, winid
end)
hover.handler = function(_, result, ctx, _)
focusable_float(ctx.method, function()
if not (result and result.contents) then
return
end
end

return function(_, result, ctx, _)
focusable_float(ctx.method, function()
if not (result and result.contents) then
return
end
local markdown_lines = lsp.util.convert_input_to_markdown_lines(result.contents)
markdown_lines = lsp.util.trim_empty_lines(markdown_lines)
if vim.tbl_isempty(markdown_lines) then
return
end
window.nvim_win_try_close()
local bufnr, winid = window.fancy_floating_markdown(markdown_lines)
local markdown_lines = lsp.util.convert_input_to_markdown_lines(result.contents)
markdown_lines = lsp.util.trim_empty_lines(markdown_lines)
if vim.tbl_isempty(markdown_lines) then
return
end
window.nvim_win_try_close()
local bufnr, winid = window.fancy_floating_markdown(markdown_lines)

lsp.util.close_preview_autocmd({
"CursorMoved",
"BufHidden",
"BufLeave",
"InsertCharPre",
}, winid)
return bufnr, winid
end)
end
end)()
lsp.util.close_preview_autocmd({
"CursorMoved",
"BufHidden",
"BufLeave",
"InsertCharPre",
}, winid)
return bufnr, winid
end)
end

function hover.render_hover_doc()
--if has diagnostic window close
Expand Down

0 comments on commit 373bc03

Please sign in to comment.