feat(git-blame): refactor git-blame lualine component

Implement git-blame lualine component via the git-blame plugin initialization
This commit is contained in:
2024-08-03 22:42:50 -04:00
parent 454168565f
commit 61bd1b6863
+32
View File
@@ -2,6 +2,24 @@
-- -------------------------------- UTILITIES ----------------------------------
-- -----------------------------------------------------------------------------
-- Function to convert RGB to hexadecimal
local function rgb_to_hex(rgb)
return string.format("#%02x%02x%02x", rgb[1], rgb[2], rgb[3])
end
local function get_fg_color(hlgroup)
local hl = vim.api.nvim_get_hl(0, { name = hlgroup, link = false })
local fg = hl.fg
if fg then
return rgb_to_hex({
bit.rshift(bit.band(fg, 0xFF0000), 16),
bit.rshift(bit.band(fg, 0x00FF00), 8),
bit.band(fg, 0x0000FF),
})
end
return nil
end
return {
{ -- Project management
import = "lazyvim.plugins.extras.util.project",
@@ -156,5 +174,19 @@ return {
{ -- Git Blame
"f-person/git-blame.nvim",
event = "VeryLazy",
opts = function()
-- Get the current lualine configuration
local config = require("lualine").get_config()
local git_blame = require("gitblame")
-- Add Git-blame to lualine_c section
table.insert(config.sections.lualine_c, {
git_blame.get_current_blame_text,
cond = git_blame.is_blame_text_available,
color = { fg = get_fg_color("GitSignsCurrentLineBlame") },
})
-- Apply the new configuration
require("lualine").setup(config)
end,
},
}