local M = { "lewis6991/gitsigns.nvim", event = "BufReadPost", opts = { signs = { add = { text = "+" }, change = { text = "~" }, delete = { text = "_" }, topdelete = { text = "‾" }, changedelete = { text = "~" }, }, on_attach = function(bufnr) local gitsigns = require("gitsigns") local function map(mode, l, r, opts) opts = opts or {} opts.buffer = bufnr vim.keymap.set(mode, l, r, opts) end -- Navigation map("n", "]c", function() if vim.wo.diff then vim.cmd.normal({ "]c", bang = true }) else gitsigns.nav_hunk("next") end end) map("n", "[c", function() if vim.wo.diff then vim.cmd.normal({ "[c", bang = true }) else gitsigns.nav_hunk("prev") end end) -- Actions map("n", "sh", gitsigns.stage_hunk) map("n", "rh", gitsigns.reset_hunk) map("v", "sh", function() gitsigns.stage_hunk({ vim.fn.line("."), vim.fn.line("v") }) end) map("v", "rh", function() gitsigns.reset_hunk({ vim.fn.line("."), vim.fn.line("v") }) end) map("n", "sH", gitsigns.stage_buffer) map("n", "rH", gitsigns.reset_buffer) map("n", "ph", gitsigns.preview_hunk) map("n", "bh", function() gitsigns.blame_line({ full = true }) end) map("n", "hd", gitsigns.diffthis) map("n", "hD", function() gitsigns.diffthis("~") end) map("n", "hQ", function() gitsigns.setqflist("all") end) map("n", "hq", gitsigns.setqflist) -- Toggles map("n", "tb", gitsigns.toggle_current_line_blame) end, }, } return M