✨ feat(git-blame): refactor git-blame lualine component
Implement git-blame lualine component via the git-blame plugin initialization
This commit is contained in:
@@ -2,6 +2,24 @@
|
|||||||
-- -------------------------------- UTILITIES ----------------------------------
|
-- -------------------------------- 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 {
|
return {
|
||||||
{ -- Project management
|
{ -- Project management
|
||||||
import = "lazyvim.plugins.extras.util.project",
|
import = "lazyvim.plugins.extras.util.project",
|
||||||
@@ -156,5 +174,19 @@ return {
|
|||||||
{ -- Git Blame
|
{ -- Git Blame
|
||||||
"f-person/git-blame.nvim",
|
"f-person/git-blame.nvim",
|
||||||
event = "VeryLazy",
|
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,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user