Skip to content

Commit

Permalink
feat: added config option for default bg when transparent #20
Browse files Browse the repository at this point in the history
Fix black background with transparent theme
  • Loading branch information
folke committed Sep 5, 2022
2 parents 6eec05c + 2607bb6 commit 04d0f27
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lua/twilight/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ local defaults = {
alpha = 0.25, -- amount of dimming
-- we try to get the foreground from the highlight groups or fallback color
color = { "Normal", "#ffffff" },
term_bg = "#000000", -- if guibg=NONE, this will be used to calculate text color
inactive = false, -- when true, other windows will be fully dimmed (unless they contain the same buffer)
},
context = 10, -- amount of lines we will try to show arounc the current line
Expand Down Expand Up @@ -48,8 +49,13 @@ function M.colors()
end
end
local normal = util.get_hl("Normal")
local bg = (normal and normal.background) or "#000000"
local dimmed = util.blend(fg, bg, M.options.dimming.alpha)
local bg = M.options.dimming.term_bg
if normal then
bg = normal.background or "NONE"
end
-- use terminal background in blend function if guibg is NONE
local bg_hex = (bg ~= "NONE") and bg or M.options.dimming.term_bg
local dimmed = util.blend(fg, bg_hex, M.options.dimming.alpha)
vim.cmd("highlight! def Twilight guifg=" .. dimmed .. " guibg=" .. bg)
end

Expand Down

0 comments on commit 04d0f27

Please sign in to comment.