diff --git a/lua/plugins/util.lua b/lua/plugins/util.lua index 5527fa9..78257e0 100644 --- a/lua/plugins/util.lua +++ b/lua/plugins/util.lua @@ -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, }, }