feat: added scrollbar option to window.completition ( #1087) (#1308)

* #1087 added hide_scrollbar option to window.completition

* Renamed hide_scrollbar to scrollbar, changed default value (#1087)

* doc description update (#1087)

* determining info.scrollbar value considering config scrollbar (#1087)

* window.bordered scrollbar default value fix (#1087)
This commit is contained in:
pure-bliss
2022-11-18 09:31:06 +01:00
committed by GitHub
parent a188be8559
commit 8a9e8a89ee
5 changed files with 11 additions and 1 deletions

View File

@@ -630,6 +630,11 @@ window.completion.side_padding~
`number`
The ammount of padding to add on the completion window's sides
*cmp-config.window.completion.scrollbar*
window.completion.scrollbar~
`boolean`
Wether the scrollbar should be enabled if there are more items that fit
*cmp-config.window.documentation.max_width*
window.documentation.max_width~
`number`

View File

@@ -95,6 +95,7 @@ return function()
scrolloff = 0,
col_offset = 0,
side_padding = 1,
scrollbar = true,
},
documentation = {
max_height = math.floor(WIDE_HEIGHT * (WIDE_HEIGHT / vim.o.lines)),

View File

@@ -9,6 +9,7 @@ window.bordered = function(opts)
scrolloff = opts.scrolloff or 0,
col_offset = opts.col_offset or 0,
side_padding = opts.side_padding or 1,
scrollbar = opts.scrollbar == nil and true or opts.scrollbar,
}
end

View File

@@ -117,6 +117,7 @@ cmp.ItemField = {
---@field public max_width integer|nil
---@field public max_height integer|nil
---@field public scrolloff integer|nil
---@field public scrollbar boolean|true
---@class cmp.ConfirmationConfig
---@field public default_behavior cmp.ConfirmBehavior

View File

@@ -1,6 +1,7 @@
local misc = require('cmp.utils.misc')
local buffer = require('cmp.utils.buffer')
local api = require('cmp.utils.api')
local config = require('cmp.config')
---@class cmp.WindowStyle
---@field public relative string
@@ -213,6 +214,7 @@ end
---Return win info.
window.info = function(self)
local border_info = self:get_border_info()
local scrollbar = config.get().window.completion.scrollbar
local info = {
row = self.style.row,
col = self.style.col,
@@ -225,7 +227,7 @@ window.info = function(self)
scrollbar_offset = 0,
}
if self:get_content_height() > info.inner_height then
if self:get_content_height() > info.inner_height and scrollbar then
info.scrollable = true
if not border_info.visible then
info.scrollbar_offset = 1