return { 'lewis6991/gitsigns.nvim', requires = 'nvim-lua/plenary.nvim', config = function () local gitsigns = require 'gitsigns' gitsigns.setup{ on_attach = function(bufnr) local function keymap_n(key, command, description, opts) opts = vim.tbl_extend('force', {noremap = true, silent = true, buffer=bufnr}, opts or {}) return {key, command, description=description, opts=opts} end local function keymap_vn(key, command, description, opts) opts = vim.tbl_extend('force', {noremap = true, silent = true, buffer=bufnr}, opts or {}) return {key, command, mode={"v", "n"}, description=description, opts=opts} end require("legendary").keymaps{ { itemgroup = "githunks", description = "Git hunks", icon = "", keymaps = { keymap_n(']c', "&diff ? ']c' : 'Gitsigns next_hunk'", "Jump to next hunk", {expr=true}), keymap_n('[c', "&diff ? '[c' : 'Gitsigns prev_hunk'", "Jump to prev hunk", {expr=true}), keymap_vn("hs", ":Gitsigns stage_hunk", "Stage hunk"), keymap_vn("hr", ":Gitsigns reset_hunk", "Reset hunk"), keymap_n("hS", "Gitsigns stage_buffer", "Stage buffer"), keymap_n("hu", "Gitsigns undo_stage_hunk", "Undo stage hunk"), keymap_n("hR", "Gitsigns reset_buffer", "Reset buffer"), keymap_n("hp", "Gitsigns preview_hunk", "Preview hunk"), keymap_n('td', 'Gitsigns toggle_deleted', "Toggle deleted"), {'ih', {o=':Gitsigns select_hunk', x=':Gitsigns select_hunk'}, description="Select hunk" } } } } end } end }