nvim-cmp
nvim-cmp copied to clipboard
[Question]: Disable Scrollbar
How to hide the scrollbar, because it looks very bad in my config:
Can I hide the scrollbar, I want to still be able to scroll with keybindings, but with a hidden scrollbar.
It would be really nice to bring back the thin scrollbar
that was introduced during the development of floating window based completion window but later removed.
thin scrollbar
looks slick!
Hey, can I even change the scrollbar characters?
@techtycho, We had this option during the development of the the floating window based completion PR. But, it was removed before integration into the main branch.
Is the scrollbar related to nvim-cmp
specifically, or just a Neovim API
feature?
The scrollbar is the original feature in nvim-cmp.
Is there anything I can do to get it right? At least make it look good on my config instead of entirely getting rid of it?
EDIT: I think I found the code responsible for drawing the scrollbar:
if info.scrollable then
-- Draw the background of the scrollbar
if not info.border_info.visible then
local style = {
relative = 'editor',
style = 'minimal',
width = 1,
height = self.style.height,
row = info.row,
col = info.col + info.width - info.scrollbar_offset, -- info.col was already contained the scrollbar offset.
zindex = (self.style.zindex and (self.style.zindex + 1) or 1),
}
if self.sbar_win and vim.api.nvim_win_is_valid(self.sbar_win) then
vim.api.nvim_win_set_config(self.sbar_win, style)
else
style.noautocmd = true
self.sbar_win = vim.api.nvim_open_win(buffer.ensure(self.name .. 'sbar_buf'), false, style)
vim.api.nvim_win_set_option(self.sbar_win, 'winhighlight', 'EndOfBuffer:PmenuSbar,NormalFloat:PmenuSbar')
end
end
-- Draw the scrollbar thumb
local thumb_height = math.floor(info.inner_height * (info.inner_height / self:get_content_height()) + 0.5)
local thumb_offset = math.floor(info.inner_height * (vim.fn.getwininfo(self.win)[1].topline / self:get_content_height()))
local style = {
relative = 'editor',
style = 'minimal',
width = 1,
height = math.max(1, thumb_height),
row = info.row + thumb_offset + (info.border_info.visible and info.border_info.top or 0),
col = info.col + info.width - 1, -- info.col was already added scrollbar offset.
zindex = (self.style.zindex and (self.style.zindex + 2) or 2),
}
if self.thumb_win and vim.api.nvim_win_is_valid(self.thumb_win) then
vim.api.nvim_win_set_config(self.thumb_win, style)
else
style.noautocmd = true
self.thumb_win = vim.api.nvim_open_win(buffer.ensure(self.name .. 'thumb_buf'), false, style)
vim.api.nvim_win_set_option(self.thumb_win, 'winhighlight', 'EndOfBuffer:PmenuThumb,NormalFloat:PmenuThumb')
end
else
if self.sbar_win and vim.api.nvim_win_is_valid(self.sbar_win) then
vim.api.nvim_win_hide(self.sbar_win)
self.sbar_win = nil
end
if self.thumb_win and vim.api.nvim_win_is_valid(self.thumb_win) then
vim.api.nvim_win_hide(self.thumb_win)
self.thumb_win = nil
end
end
I think PmenuThumb
is the highlight group for the scrollbar thumb, but the rest of the code is messy, I'll try to read and understand it, in case a pull request is necessary.
Any news on this?
@Alex-vZyl I just deleted the if statement on my copy of nvim-cmp. All seems to work for me. I guess we just wait if this is every implemented but it should be pretty trivial if dodging the if block is the solution.
https://github.com/hrsh7th/nvim-cmp/pull/1308 should answer this:
cmp.setup({
window = {
completion = {
scrollbar = false,
},
},
})