From 8bae5af93a305a98b489817901bdf52e3bc29cdf Mon Sep 17 00:00:00 2001 From: bekaboo <18127878294@qq.com> Date: Sat, 15 Jun 2024 03:05:12 +0800 Subject: [PATCH] refactor(hlgroups): move def of `clear_winbar_bg()` out of `init()` --- lua/dropbar/hlgroups.lua | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/lua/dropbar/hlgroups.lua b/lua/dropbar/hlgroups.lua index 1298ea21..c094f653 100644 --- a/lua/dropbar/hlgroups.lua +++ b/lua/dropbar/hlgroups.lua @@ -92,6 +92,24 @@ local function set_hlgroups() end end +---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 + ---Initialize highlight groups for dropbar local function init() local groupid = vim.api.nvim_create_augroup('DropBarHlGroups', {}) @@ -105,25 +123,6 @@ local function init() -- 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.',