return { { "tpope/vim-fugitive" }, --{ "tpope/vim-rhubarb" }, --If fugitive.vim is the Git, rhubarb.vim is the Hub. { -- Adds git related signs to the gutter, as well as utilities for managing changes "lewis6991/gitsigns.nvim", opts = { -- See `:help gitsigns.txt` signs = { add = { text = "+" }, change = { text = "~" }, delete = { text = "_" }, topdelete = { text = "‾" }, changedelete = { text = "~" }, untracked = { text = "▎" }, }, on_attach = function(bufnr) local gs = package.loaded.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", "v" }, "]h", function() if vim.wo.diff then return "]h" end vim.schedule(function() gs.next_hunk() end) return "" end, { expr = true, desc = "Jump to next git hunk" }) map({ "n", "v" }, "[h", function() if vim.wo.diff then return "[h" end vim.schedule(function() gs.prev_hunk() end) return "" end, { expr = true, desc = "Jump to previous git hunk" }) -- Actions -- visual mode map("v", "ghr", function() gs.reset_hunk({ vim.fn.line("."), vim.fn.line("v") }) end, { desc = "reset git hunk" }) -- normal mode map("n", "ghp", gs.preview_hunk, { desc = "preview git hunk" }) map("n", "gp", gs.preview_hunk, { desc = "preview git hunk" }) map("n", "ghr", gs.reset_hunk, { desc = "git reset hunk" }) map("n", "ghb", function() gs.blame_line({ full = false }) end, { desc = "git blame line" }) map("n", "ghD", gs.diffthis, { desc = "git diff against index" }) map("n", "ghd", function() gs.diffthis("~") end, { desc = "git diff against last commit" }) -- Toggles map("n", "gtb", gs.toggle_current_line_blame, { desc = "toggle git blame line" }) map("n", "gtd", gs.toggle_deleted, { desc = "toggle git show deleted" }) -- Text object map({ "o", "x" }, "gih", ":Gitsigns select_hunk", { desc = "select git hunk" }) end, }, }, }