Skip to content

Commit

Permalink
feat(gitsigns): improve change preview (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
ramojus authored Oct 26, 2024
1 parent d012f93 commit 7fbcccd
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions lua/mellifluous/highlights/plugins/gitsigns.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
local M = {}

local function replicate_floating_shade(hl, diff_bg_color)
local shader = require("mellifluous.utils.shader")
return shader.replicate_shade(hl.get("Normal").bg, hl.get("NormalFloat").bg, diff_bg_color)
end

function M.set(hl, colors)
local bg = hl.get("SignColumn").bg
local config = require("mellifluous.config").config

-- signs
if config.is_bg_dark then
hl.set("GitSignsAdd", { fg = colors.green:with_lightness(40):with_saturation(60), bg = bg })
hl.set("GitSignsChange", { fg = colors.orange:with_lightness(55):with_saturation(80), bg = bg })
Expand All @@ -13,6 +19,21 @@ function M.set(hl, colors)
hl.set("GitSignsChange", { fg = colors.orange:with_lightness(70):with_saturation(80), bg = bg })
hl.set("GitSignsDelete", { fg = colors.red:with_lightness(75):with_saturation(80), bg = bg })
end

-- preview of change
hl.set("GitSignsDeletePreview", { bg = replicate_floating_shade(hl, hl.get("DiffDelete").bg) })
hl.set("GitSignsAddPreview", { bg = replicate_floating_shade(hl, hl.get("DiffAdd").bg) })
hl.set("GitSignsChangePreview", { bg = replicate_floating_shade(hl, hl.get("DiffChange").bg) })

local inline_lightnened_val = 8
hl.set("GitSignsDeleteInline", { bg = hl.get("GitSignsDeletePreview").bg:lightened(inline_lightnened_val) })
hl.set("GitSignsAddInline", { bg = hl.get("GitSignsAddPreview").bg:lightened(inline_lightnened_val) })
hl.set("GitSignsChangeInline", { bg = hl.get("GitSignsChangePreview").bg:lightened(inline_lightnened_val) })

-- in-place preview of change (without floating window)
hl.set("GitSignsDeleteLnInline", { bg = hl.get("DiffDelete").bg:lightened(inline_lightnened_val) })
hl.set("GitSignsAddLnInline", { bg = hl.get("DiffAdd").bg:lightened(inline_lightnened_val) })
hl.set("GitSignsChangeLnInline", { bg = hl.get("DiffChange").bg:lightened(inline_lightnened_val) })
end

return M

0 comments on commit 7fbcccd

Please sign in to comment.