return { "lewis6991/gitsigns.nvim", event = { "BufReadPre", "BufNewFile" }, opts = { signs = { add = { text = "+" }, change = { text = "~" }, delete = { text = "_" }, topdelete = { text = "‾" }, changedelete = { text = "~" }, }, on_attach = function(bufnr) local gs = package.loaded.gitsigns local function map(mode, l, r, desc) vim.keymap.set(mode, l, r, { buffer = bufnr, desc = desc }) end -- Navigation map("n", "]h", gs.next_hunk, "Next Hunk") map("n", "[h", gs.prev_hunk, "Prev Hunk") -- Actions map("n", "hs", gs.stage_hunk, "Stage hunk") map("n", "hr", gs.reset_hunk, "Reset hunk") map("v", "hs", function() gs.stage_hunk({ vim.fn.line("."), vim.fn.line("v") }) end, "Stage hunk") map("v", "hr", function() gs.reset_hunk({ vim.fn.line("."), vim.fn.line("v") }) end, "Reset hunk") map("n", "hS", gs.stage_buffer, "Stage buffer") map("n", "hR", gs.reset_buffer, "Reset buffer") map("n", "hu", gs.undo_stage_hunk, "Undo stage hunk") map("n", "hp", gs.preview_hunk, "Preview hunk") map("n", "hb", function() gs.blame_line({ full = true }) end, "Blame line") map( "n", "hB", gs.toggle_current_line_blame, "Toggle line blame" ) map("n", "hd", gs.diffthis, "Diff this") map("n", "hD", function() gs.diffthis("~") end, "Diff this ~") -- Text object map( { "o", "x" }, "ih", ":Gitsigns select_hunk", "Gitsigns select hunk" ) end, }, }