return { "lewis6991/gitsigns.nvim", main = "gitsigns", opts = { on_attach = function(bufnr) local gs = package.loaded.gitsigns local function m(mode, l, r, opts) opts = opts or {} opts.buffer = bufnr vim.keymap.set(mode, l, r, opts) end m("n", "]h", function() if vim.wo.diff then return "]c" end vim.schedule(function() gs.next_hunk() end) return "" end, {expr=true}) m('n', '[h', function() if vim.wo.diff then return '[c' end vim.schedule(function() gs.prev_hunk() end) return '' end, {expr=true}) m('n', 'hs', gs.stage_hunk) m('n', 'hr', gs.reset_hunk) m('v', 'hs', function() gs.stage_hunk {vim.fn.line("."), vim.fn.line("v")} end) m('v', 'hr', function() gs.reset_hunk {vim.fn.line("."), vim.fn.line("v")} end) m('n', 'hS', gs.stage_buffer) m('n', 'hu', gs.undo_stage_hunk) m('n', 'hR', gs.reset_buffer) m('n', 'hp', gs.preview_hunk) m('n', 'hb', function() gs.blame_line{full=true} end) m('n', 'tb', gs.toggle_current_line_blame) m('n', 'hd', gs.diffthis) m('n', 'hD', function() gs.diffthis('~') end) m('n', 'td', gs.toggle_deleted) end, }, config = function (lazyplug, opts) require(lazyplug.main).setup(opts) end, }