Skip to content

Commit

Permalink
feat(hlgroups): add workaround for winbar background issue (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
bekaboo committed Jun 14, 2024
1 parent cd79d3c commit 98aec7c
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion lua/dropbar/hlgroups.lua
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,48 @@ end

---Initialize highlight groups for dropbar
local function init()
local groupid = vim.api.nvim_create_augroup('DropBarHlGroups', {})

set_hlgroups()
vim.api.nvim_create_autocmd('ColorScheme', {
group = vim.api.nvim_create_augroup('DropBarHlGroups', {}),
group = groupid,
callback = set_hlgroups,
})

-- Remove winbar background as a workaround for
-- https://github.com/Bekaboo/dropbar.nvim/issues/118, also see
-- https://github.com/neovim/neovim/issues/26037#issuecomment-1838548013

---Set WinBar & WinBarNC background to Normal background
---@return nil
local function clear_winbar_bg()
---@param name string
---@return nil
local function _clear_bg(name)
local hl = vim.api.nvim_get_hl(0, { name = name, link = false })
if hl.bg or hl.ctermbg then
hl.bg = nil
hl.ctermbg = nil
vim.api.nvim_set_hl(0, name, hl)
end
end

_clear_bg('WinBar')
_clear_bg('WinBarNC')
end

clear_winbar_bg()
vim.api.nvim_create_autocmd('ColorScheme', {
desc = 'Remove WinBar background color as a workaround.',
group = groupid,
callback = clear_winbar_bg,
})
vim.api.nvim_create_autocmd('OptionSet', {
desc = 'Remove WinBar background color as a workaround.',
pattern = 'background',
group = groupid,
callback = clear_winbar_bg,
})
end

return {
Expand Down

0 comments on commit 98aec7c

Please sign in to comment.