refactor: move is_transparent to util

This commit is contained in:
Folke Lemaitre 2024-12-03 10:29:21 +01:00
parent 089ff668d2
commit 96ac87b6b1
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
2 changed files with 14 additions and 12 deletions

View file

@ -110,4 +110,18 @@ function M.blend(fg, bg, alpha)
return string.format("#%02x%02x%02x", blend(1), blend(2), blend(3))
end
local transparent ---@type boolean?
function M.is_transparent()
if transparent == nil then
transparent = M.color("Normal", "bg") == nil
vim.api.nvim_create_autocmd("ColorScheme", {
group = vim.api.nvim_create_augroup("snacks_util_transparent", { clear = true }),
callback = function()
transparent = nil
end,
})
end
return transparent
end
return M