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

@@ -3,6 +3,7 @@
lua package.loaded['tokyonight'] = nil lua package.loaded['tokyonight'] = nil
lua package.loaded['tokyonight.theme'] = nil lua package.loaded['tokyonight.theme'] = nil
lua package.loaded['tokyonight.colors'] = nil lua package.loaded['tokyonight.colors'] = nil
lua package.loaded['tokyonight.util'] = nil
lua package.loaded['tokyonight.config'] = nil lua package.loaded['tokyonight.config'] = nil
lua require('tokyonight').colorscheme() lua require('tokyonight').colorscheme()

View File

@@ -29,10 +29,13 @@ local colors = {
teal = "#1abc9c", teal = "#1abc9c",
red = "#f7768e", red = "#f7768e",
red1 = "#db4b4b", 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 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_highlight = colors.blue0
colors.border = colors.black colors.border = colors.black
@@ -40,7 +43,7 @@ colors.bg_popup = colors.bg_dark
colors.bg_sidebar = colors.bg_dark colors.bg_sidebar = colors.bg_dark
colors.bg_statusline = colors.bg_dark colors.bg_statusline = colors.bg_dark
colors.bg_float = colors.bg 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.bg_search = colors.blue0
colors.fg_sidebar = colors.fg_dark colors.fg_sidebar = colors.fg_dark
@@ -49,7 +52,6 @@ colors.warning = colors.yellow
colors.info = colors.teal colors.info = colors.teal
colors.hint = colors.info colors.hint = colors.info
util.bg = colors.bg
-- util.fg = colors.fg -- util.fg = colors.fg
return colors return colors

View File

@@ -16,24 +16,20 @@ local function hexToRgb(hex_str)
return { tonumber(r, 16), tonumber(g, 16), tonumber(b, 16) } return { tonumber(r, 16), tonumber(g, 16), tonumber(b, 16) }
end end
local function luma(color, alpha, bg) local function blend(fg, bg, alpha)
bg = bg or util.bg
bg = hexToRgb(bg) bg = hexToRgb(bg)
color = hexToRgb(color) fg = hexToRgb(fg)
alpha = 1 - ((alpha or 0) / 100) local blendChannel = function(i)
local ret = (alpha * (fg[i]) + ((1 - alpha) * (bg[i])))
local blend = function(i) return math.floor(math.min(math.max(0, ret), 255) + .5)
return math.floor(math.min(math.max(0, (alpha * (color[i]) + ((1 - alpha) * (bg[i])))), 255) +
.5)
end 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 end
function util.darken(hex, amount) return luma(hex, math.abs(amount), util.bg) end function util.darken(hex, amount, bg) return blend(hex, bg or util.bg, math.abs(amount)) end
function util.lighten(hex, amount) return luma(hex, math.abs(amount), util.fg) end function util.lighten(hex, amount, fg) return blend(hex, fg or util.fg, math.abs(amount)) end
function util.highlight(group, color) function util.highlight(group, color)
if color.fg then util.colorsUsed[color.fg] = true end if color.fg then util.colorsUsed[color.fg] = true end