Skip to content

Commit

Permalink
fix: set CursorLine hl to visible color
Browse files Browse the repository at this point in the history
  • Loading branch information
scottmckendry committed Apr 30, 2024
1 parent d777f1b commit 528085b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lua/cyberdream/theme.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local colors = require("cyberdream.colors")
local util = require("cyberdream.util")

local M = {}
function M.setup()
Expand Down Expand Up @@ -40,7 +41,7 @@ function M.setup()
ICursor = { fg = t.bg, bg = t.fg },
CursorIM = { fg = t.bg, bg = t.fg },
CursorColumn = { bg = t.bgHighlight },
CursorLine = { bg = t.bg },
CursorLine = { bg = (util.blend(t.bgAlt, t.bgHighlight)) },
Directory = { fg = t.blue },
DiffAdd = { fg = t.green },
DiffChange = { fg = t.cyan },
Expand Down
18 changes: 18 additions & 0 deletions lua/cyberdream/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,22 @@ function M.load(theme)
M.syntax(theme.highlights)
end

--- Blend two colors together based on a weight.
--- @param color1 string
--- @param color2 string
--- @param weight? number
--- @return string
function M.blend(color1, color2, weight)
weight = weight or 0.5

local rgb1 = { tonumber(color1:sub(2, 3), 16), tonumber(color1:sub(4, 5), 16), tonumber(color1:sub(6, 7), 16) }
local rgb2 = { tonumber(color2:sub(2, 3), 16), tonumber(color2:sub(4, 5), 16), tonumber(color2:sub(6, 7), 16) }
local rgb_blended = {}
for i = 1, 3 do
rgb_blended[i] = math.floor(rgb1[i] * weight + rgb2[i] * (1 - weight))
end

return string.format("#%02x%02x%02x", rgb_blended[1], rgb_blended[2], rgb_blended[3])
end

return M

0 comments on commit 528085b

Please sign in to comment.