From 349218ca9d75478c001027c676a2b4450b7b1913 Mon Sep 17 00:00:00 2001 From: Akulij Date: Sat, 3 May 2025 16:18:36 +0300 Subject: [PATCH] add blame.nvim --- lua/plugins/git.lua | 69 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 67 insertions(+), 2 deletions(-) diff --git a/lua/plugins/git.lua b/lua/plugins/git.lua index 1f05e14..b3baad1 100644 --- a/lua/plugins/git.lua +++ b/lua/plugins/git.lua @@ -4,7 +4,6 @@ return { dependencies = { "nvim-lua/plenary.nvim", -- required "sindrets/diffview.nvim", -- optional - Diff integration - -- Only one of these is needed. "nvim-telescope/telescope.nvim", -- optional "ibhagwan/fzf-lua", -- optional @@ -24,5 +23,71 @@ return { vim.keymap.set('n', 'h', gitsigns.next_hunk, { noremap = true, silent = true }) end, - } + }, + { + "FabijanZulj/blame.nvim", + lazy = false, + colors = { + "#b8cc52", + "#36a3d9", + "#e6e1cf", + }, + config = function() + require('blame').setup { + format_fn = function (line_porcelain, config, idx) + local utils = require("blame.utils") + + local hash = string.sub(line_porcelain.hash, 0, 7) + local line_with_hl = {} + local is_commited = hash ~= "0000000" + + if is_commited then + local summary + if #line_porcelain.summary > config.max_summary_width then + summary = string.sub( + line_porcelain.summary, + 0, + config.max_summary_width - 3 + ) .. "..." + else + summary = line_porcelain.summary + end + line_with_hl = { + idx = idx, + values = { + { + textValue = utils.format_time( + config.date_format, + line_porcelain.committer_time + ), + hl = "Comment", + }, + { + textValue = line_porcelain.author .. ":", + hl = hash, + }, + { + textValue = summary, + hl = hash, + }, + }, + format = "%s %s", + } + else + line_with_hl = { + idx = idx, + values = { + { + textValue = "Not commited yet", + hl = "Comment", + }, + }, + format = "%s", + } + end + return line_with_hl + end + } + end, + }, }