better git colors

This commit is contained in:
Folke Lemaitre
2021-04-19 20:43:20 +02:00
parent 77965fc936
commit 07fca7366b
3 changed files with 15 additions and 16 deletions

View File

@@ -29,10 +29,13 @@ local colors = {
teal = "#1abc9c",
red = "#f7768e",
red1 = "#db4b4b",
diff = { add = "#164846", delete = "#823c41", change = "#394b70" },
diff = { change = "#394b70", add = "#164846", delete = "#823c41" },
git = { change = "#6183bb", add = "#449dab", delete = "#914c54" },
}
colors.black = util.darken(colors.bg_dark, 10)
if config.style == "night" then colors.bg = "#1a1b26" end
util.bg = colors.bg
colors.git.ignore = colors.dark3
colors.black = util.darken(colors.bg, 0.7, "#000000")
colors.border_highlight = colors.blue0
colors.border = colors.black
@@ -40,7 +43,7 @@ colors.bg_popup = colors.bg_dark
colors.bg_sidebar = colors.bg_dark
colors.bg_statusline = colors.bg_dark
colors.bg_float = colors.bg
colors.bg_visual = util.darken(colors.blue0, 30)
colors.bg_visual = util.darken(colors.blue0, 0.7)
colors.bg_search = colors.blue0
colors.fg_sidebar = colors.fg_dark
@@ -49,7 +52,6 @@ colors.warning = colors.yellow
colors.info = colors.teal
colors.hint = colors.info
util.bg = colors.bg
-- util.fg = colors.fg
return colors

View File

@@ -16,24 +16,20 @@ local function hexToRgb(hex_str)
return { tonumber(r, 16), tonumber(g, 16), tonumber(b, 16) }
end
local function luma(color, alpha, bg)
bg = bg or util.bg
local function blend(fg, bg, alpha)
bg = hexToRgb(bg)
color = hexToRgb(color)
fg = hexToRgb(fg)
alpha = 1 - ((alpha or 0) / 100)
local blend = function(i)
return math.floor(math.min(math.max(0, (alpha * (color[i]) + ((1 - alpha) * (bg[i])))), 255) +
.5)
local blendChannel = function(i)
local ret = (alpha * (fg[i]) + ((1 - alpha) * (bg[i])))
return math.floor(math.min(math.max(0, ret), 255) + .5)
end
return string.format("#%02X%02X%02X", blend(1), blend(2), blend(3))
return string.format("#%02X%02X%02X", blendChannel(1), blendChannel(2), blendChannel(3))
end
function util.darken(hex, amount) return luma(hex, math.abs(amount), util.bg) end
function util.lighten(hex, amount) return luma(hex, math.abs(amount), util.fg) end
function util.darken(hex, amount, bg) return blend(hex, bg or util.bg, math.abs(amount)) end
function util.lighten(hex, amount, fg) return blend(hex, fg or util.fg, math.abs(amount)) end
function util.highlight(group, color)
if color.fg then util.colorsUsed[color.fg] = true end