Merge branch 'main' of https://github.com/rose-pine/neovim into rose-pine-main

This commit is contained in:
Eric 2023-08-24 12:44:43 -07:00
commit 139cd93be7
14 changed files with 827 additions and 683 deletions

View file

@ -31,31 +31,35 @@ 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]))
return math.floor(math.min(math.max(0, ret), 255) + 0.5)
end
local function blend_channel(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
return string.format("#%02X%02X%02X", blend_channel(1), blend_channel(2),
blend_channel(3))
end
---@param group string
---@param color table<string, string>
---@param color table<string, any>
util.highlight = function(group, color)
local style = color.style and "gui=" .. color.style or "gui=NONE"
local fg = color.fg and "guifg=" .. parse_color(color.fg) or "guifg=NONE"
local bg = color.bg and "guibg=" .. parse_color(color.bg) or "guibg=NONE"
local sp = color.sp and "guisp=" .. parse_color(color.sp) or ""
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 ''
vim.cmd(string.format("highlight %s %s %s %s %s", group, style, fg, bg, sp))
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
if color.link then
vim.cmd(string.format("highlight! link %s %s", group, color.link))
end
color = vim.tbl_extend('force', color, { fg = fg, bg = bg, sp = sp })
vim.api.nvim_set_hl(0, group, color)
end
return util