diff --git a/lua/cmp/view.lua b/lua/cmp/view.lua index a1b7c153d..3381d71c8 100644 --- a/lua/cmp/view.lua +++ b/lua/cmp/view.lua @@ -171,7 +171,8 @@ view.open_docs = function(self) if not self:visible() then return end - self.docs_view:open(e, self:_get_entries_view():info()) + local bottom_up = self.custom_entries_view.bottom_up + self.docs_view:open(e, self:_get_entries_view():info(), bottom_up) end))) end end @@ -268,7 +269,8 @@ view.on_entry_change = async.throttle(function(self) return end if self.is_docs_view_pinned or config.get().view.docs.auto_open then - self.docs_view:open(e, self:_get_entries_view():info()) + local bottom_up = self.custom_entries_view.bottom_up + self.docs_view:open(e, self:_get_entries_view():info(), bottom_up) end end))) else diff --git a/lua/cmp/view/custom_entries_view.lua b/lua/cmp/view/custom_entries_view.lua index ca73c8946..2e2ea0f63 100644 --- a/lua/cmp/view/custom_entries_view.lua +++ b/lua/cmp/view/custom_entries_view.lua @@ -16,6 +16,7 @@ local DEFAULT_HEIGHT = 10 -- @see https://github.com/vim/vim/blob/master/src/pop ---@field private active boolean ---@field private entries cmp.Entry[] ---@field private column_width any +---@field private bottom_up boolean ---@field public event cmp.Event local custom_entries_view = {} diff --git a/lua/cmp/view/docs_view.lua b/lua/cmp/view/docs_view.lua index 3947e33f8..3a13bcb94 100644 --- a/lua/cmp/view/docs_view.lua +++ b/lua/cmp/view/docs_view.lua @@ -25,7 +25,8 @@ end ---Open documentation window ---@param e cmp.Entry ---@param view cmp.WindowStyle -docs_view.open = function(self, e, view) +---@param bottom_up boolean +docs_view.open = function(self, e, view, bottom_up) local documentation = config.get().window.documentation if not documentation then return @@ -90,6 +91,8 @@ docs_view.open = function(self, e, view) return self:close() end + local row = bottom_up and math.max(view.row - (height + border_info.vert - view.height), 1) or view.row + -- Render window. self.window:option('winblend', vim.o.pumblend) self.window:option('winhighlight', documentation.winhighlight) @@ -98,7 +101,7 @@ docs_view.open = function(self, e, view) style = 'minimal', width = width, height = height, - row = view.row, + row = row, col = col, border = documentation.border, zindex = documentation.zindex or 50,