diff --git a/lua/rose-pine/theme.lua b/lua/rose-pine/theme.lua index 294ab8b..db72202 100644 --- a/lua/rose-pine/theme.lua +++ b/lua/rose-pine/theme.lua @@ -1,5 +1,3 @@ -local blend = require('rose-pine.util').blend - local M = {} function M.get(config) @@ -29,10 +27,10 @@ function M.get(config) CursorLineNr = { fg = p.text }, DarkenedPanel = { bg = groups.panel }, DarkenedStatusline = { bg = groups.panel }, - DiffAdd = { bg = blend(groups.git_add, groups.background, 0.2) }, + DiffAdd = { bg = groups.git_add, blend = 20 }, DiffChange = { bg = p.overlay }, - DiffDelete = { bg = blend(groups.git_delete, groups.background, 0.2) }, - DiffText = { bg = blend(groups.git_text, groups.background, 0.2) }, + DiffDelete = { bg = groups.git_delete, blend = 20 }, + DiffText = { bg = groups.git_text, blend = 20 }, diffAdded = { link = 'DiffAdd' }, diffChanged = { link = 'DiffChange' }, diffRemoved = { link = 'DiffDelete' }, diff --git a/lua/rose-pine/util.lua b/lua/rose-pine/util.lua index 9ee34e0..f8b84f9 100644 --- a/lua/rose-pine/util.lua +++ b/lua/rose-pine/util.lua @@ -33,11 +33,11 @@ end ---@param bg string background color ---@param alpha number number between 0 (background) and 1 (foreground) util.blend = function(fg, bg, alpha) - fg = rgb(parse_color(fg)) - bg = rgb(parse_color(bg)) + local fg_rgb = rgb(parse_color(fg)) + local bg_rgb = rgb(parse_color(bg)) local function blend_channel(i) - local ret = (alpha * fg[i] + ((1 - alpha) * bg[i])) + local ret = (alpha * fg_rgb[i] + ((1 - alpha) * bg_rgb[i])) return math.floor(math.min(math.max(0, ret), 255) + 0.5) end @@ -50,12 +50,20 @@ util.blend = function(fg, bg, alpha) end ---@param group string ----@param color table +---@param color table util.highlight = function(group, color) local fg = color.fg and parse_color(color.fg) or 'none' local bg = color.bg and parse_color(color.bg) or 'none' local sp = color.sp and parse_color(color.sp) or '' + if + color.blend ~= nil + and (color.blend >= 0 or color.blend <= 100) + and bg ~= nil + then + bg = util.blend(bg, parse_color('base') or '', color.blend / 100) + end + color = vim.tbl_extend('force', color, { fg = fg, bg = bg, sp = sp }) vim.api.nvim_set_hl(0, group, color) end diff --git a/readme.md b/readme.md index 973625b..f44b0b7 100644 --- a/readme.md +++ b/readme.md @@ -85,7 +85,11 @@ require('rose-pine').setup({ -- Change specific vim highlight groups highlight_groups = { - ColorColumn = { bg = 'rose' } + ColorColumn = { bg = 'rose' }, + + -- Blend colours against the "base" background + CursorLine = { bg = 'foam', blend = 10 }, + StatusLine = { fg = 'love', bg = 'love', blend = 10 }, } })