return { -- Gutter signs, hunk navigation, inline blame { "lewis6991/gitsigns.nvim", event = { "BufReadPost", "BufNewFile" }, opts = { signs = { add = { text = "▎" }, change = { text = "▎" }, delete = { text = "" }, topdelete = { text = "" }, changedelete = { text = "▎" }, untracked = { text = "▎" }, }, on_attach = function(bufnr) local gs = package.loaded.gitsigns local map = function(mode, lhs, rhs, desc) vim.keymap.set(mode, lhs, rhs, { buffer = bufnr, desc = desc }) end -- Navigation map("n", "]h", function() if vim.wo.diff then return "]h" end vim.schedule(function() gs.next_hunk() end) return "" end, "Next hunk") map("n", "[h", function() if vim.wo.diff then return "[h" end vim.schedule(function() gs.prev_hunk() end) return "" end, "Prev hunk") -- Actions map("n", "hs", gs.stage_hunk, "Stage hunk") map("n", "gu", gs.undo_stage_hunk, "Undo stage hunk") map("n", "gh", gs.preview_hunk, "Preview hunk") map("n", "hb", gs.toggle_current_line_blame, "Toggle blame") map("n", "gb", gs.toggle_current_line_blame, "Toggle blame") map("n", "gd", gs.diffthis, "Diff this") end, }, }, -- Split diff view and file history { "sindrets/diffview.nvim", cmd = { "DiffviewOpen", "DiffviewClose", "DiffviewFileHistory" }, keys = { { "gD", "DiffviewOpen", desc = "Diff working tree" }, { "gH", "DiffviewFileHistory %", desc = "File history" }, }, }, -- Magit-style full git interface { "NeogitOrg/neogit", dependencies = { "nvim-lua/plenary.nvim", "sindrets/diffview.nvim", "nvim-telescope/telescope.nvim", }, cmd = "Neogit", keys = { { "gg", "Neogit", desc = "Neogit" }, }, opts = { integrations = { telescope = true, diffview = true, }, }, }, }