Fix float document not displaying (#171)
This commit is contained in:
@@ -26,6 +26,15 @@ float.show = function(self, e)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local pum = vim.fn.pum_getpos() or {}
|
||||||
|
if not pum.col then
|
||||||
|
return self:close()
|
||||||
|
end
|
||||||
|
|
||||||
|
local right_space = vim.o.columns - (pum.col + pum.width + (pum.scrollbar and 1 or 0)) - 1
|
||||||
|
local left_space = pum.col - 1
|
||||||
|
local maxwidth = math.min(documentation.maxwidth, math.max(left_space, right_space))
|
||||||
|
|
||||||
-- update buffer content if needed.
|
-- update buffer content if needed.
|
||||||
if not self.entry or e.id ~= self.entry.id then
|
if not self.entry or e.id ~= self.entry.id then
|
||||||
local documents = e:get_documentation()
|
local documents = e:get_documentation()
|
||||||
@@ -37,28 +46,21 @@ float.show = function(self, e)
|
|||||||
self.buf = vim.api.nvim_create_buf(false, true)
|
self.buf = vim.api.nvim_create_buf(false, true)
|
||||||
vim.api.nvim_buf_set_option(self.buf, 'bufhidden', 'wipe')
|
vim.api.nvim_buf_set_option(self.buf, 'bufhidden', 'wipe')
|
||||||
vim.lsp.util.stylize_markdown(self.buf, documents, {
|
vim.lsp.util.stylize_markdown(self.buf, documents, {
|
||||||
max_width = documentation.maxwidth,
|
max_width = maxwidth,
|
||||||
max_height = documentation.maxheight,
|
max_height = documentation.maxheight,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
local width, height = vim.lsp.util._make_floating_popup_size(vim.api.nvim_buf_get_lines(self.buf, 0, -1, false), {
|
local width, height = vim.lsp.util._make_floating_popup_size(vim.api.nvim_buf_get_lines(self.buf, 0, -1, false), {
|
||||||
max_width = documentation.maxwidth,
|
max_width = maxwidth,
|
||||||
max_height = documentation.maxheight,
|
max_height = documentation.maxheight,
|
||||||
})
|
})
|
||||||
if width <= 0 or height <= 0 then
|
if width <= 0 or height <= 0 then
|
||||||
return self:close()
|
return self:close()
|
||||||
end
|
end
|
||||||
|
|
||||||
local pum = vim.fn.pum_getpos() or {}
|
|
||||||
if not pum.col then
|
|
||||||
return self:close()
|
|
||||||
end
|
|
||||||
|
|
||||||
local right_col = pum.col + pum.width + (pum.scrollbar and 1 or 0)
|
local right_col = pum.col + pum.width + (pum.scrollbar and 1 or 0)
|
||||||
local right_space = vim.o.columns - right_col - 1
|
|
||||||
local left_col = pum.col - width - 3 -- TODO: Why is this needed -3?
|
local left_col = pum.col - width - 3 -- TODO: Why is this needed -3?
|
||||||
local left_space = pum.col - 1
|
|
||||||
|
|
||||||
local col
|
local col
|
||||||
if right_space >= width and left_space >= width then
|
if right_space >= width and left_space >= width then
|
||||||
|
|||||||
Reference in New Issue
Block a user