Open HacksPloiter opened 6 months ago
Hm...
The highlight does not support.
https://github.com/hrsh7th/nvim-cmp/blob/main/doc/cmp.txt#L381
I have read the source code.
cmp-config.window.completion.winhighlight
only works for main completion window.
The scrollbar is another window. So your config does not work.
Please see the code.
local window = {}
window.bordered = function(opts)
opts = opts or {}
return {
border = opts.border or 'rounded',
winhighlight = opts.winhighlight or 'Normal:Normal,FloatBorder:FloatBorder,CursorLine:Visual,Search:None',
zindex = opts.zindex or 1001,
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
return window
-- 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)
opt.win_set_option(self.thumb_win, 'winhighlight', 'EndOfBuffer:PmenuThumb,NormalFloat:PmenuThumb')
end
cmp-config.window.scrollbar.winhighlight
is needed for the feature.
I have read the source code.
cmp-config.window.completion.winhighlight
only works for main completion window. The scrollbar is another window. So your config does not work.Please see the code.
local window = {} window.bordered = function(opts) opts = opts or {} return { border = opts.border or 'rounded', winhighlight = opts.winhighlight or 'Normal:Normal,FloatBorder:FloatBorder,CursorLine:Visual,Search:None', zindex = opts.zindex or 1001, 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 return window
-- 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) opt.win_set_option(self.thumb_win, 'winhighlight', 'EndOfBuffer:PmenuThumb,NormalFloat:PmenuThumb') end
cmp-config.window.scrollbar.winhighlight
is needed for the feature.
Thanks for the response. I tried with the scrollbar config you shared cmp-config.window.scrollbar
, in below fashion. It still didn't work. Interestingly other components such as border colour are taking effect.
window = {
documentation = cmp.config.window.bordered({
winhighlight = "Normal:None,FloatBorder:CmpDocFloatBorder,Search:None",
}),
completion = cmp.config.window.bordered({
winhighlight = "Normal:None,"..
"FloatBorder:CmpComFloatBorder,"..
"CursorLine:PmenuSel,"..
"Search:None",
}),
scrollbar = {
winhighlight = "PmenuSbar:CmpSbPmenuSbar,"..
"Scrollbar:CmpSbScrollbar,"..
"PmenuThumb:CmpSbPmenuThumb,",
},
},
-- LSP settings (for overriding per client)
experimental = {
ghost_text = false,
native_menu = false,
},
}
-- Customise pop-up window colours
vim.cmd([[
highlight! CmpDocFloatBorder guibg=None guifg=#00ff00"
highlight! CmpComFloatBorder guibg=None guifg=#00ff00"
highlight! CmpSbPmenuSbar guibg=blue guifg=red"
highlight! CmpSbScrollbar guibg=blue guifg=#00ff00"
highlight! CmpSbPmenuThumb guibg=yellow guifg=#00ff00"]])
also I had this doubt, I found below from the :h cmp-config.window.completion.scrollbar
*cmp-config.window.completion.scrollbar*
window.completion.scrollbar~
`boolean`
Whether the scrollbar should be enabled if there are more items that fit
but didn't find any scrollbar highlight related thing here.
Can you please share the config snippet if you meant something different (or if I didn't get it correctly)? Thanks @Shougo
Thanks for the response. I tried with the scrollbar config you shared cmp-config.window.scrollbar, in below fashion. It still didn't work. Interestingly other components such as border colour are taking effect.
Sorry. cmp-config.window.scrollbar.winhighlight
is not implemented. So it does not work unfortunately.
You can implement the feature. Because it is open source.
Thanks for the response. I tried with the scrollbar config you shared cmp-config.window.scrollbar, in below fashion. It still didn't work. Interestingly other components such as border colour are taking effect.
Sorry.
cmp-config.window.scrollbar.winhighlight i
is not implemented. So it does not work unfortunately. You can implement the feature. Because it is open source.
Hi @Shougo, Thanks for your response. Sure, I'll find time and raise a pull request adding this feature. Amazing plugin, I must admit, thanks to all the contributors and the author.
note: related PR #1741 (not exactly the solution that was mentioned though)
FAQ
Announcement
Minimal reproducible full config
and colours are:
Description
The highlights are not taking effect for popup window scroll bar. Did several experiments with configurations and colours but couldn't achieve the same!
Steps to reproduce
Configure the scrollbar highlights as per the snippet shared.
Expected behavior
Colours should change.
Actual behavior
Colours are not changing.
Additional context
No response