mirror of
https://github.com/rose-pine/neovim.git
synced 2025-10-15 12:38:53 +02:00
feat: support custom highlight blending
Example:
```
{
highlight_groups = {
StatusLine = { bg = 'love', blend = 10 }
}
}
```
This commit is contained in:
parent
eda49fde9e
commit
93c760b393
3 changed files with 20 additions and 10 deletions
|
|
@ -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' },
|
||||
|
|
|
|||
|
|
@ -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<string, string>
|
||||
---@param color table<string, any>
|
||||
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
|
||||
|
|
|
|||
|
|
@ -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 },
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue