Files
nvim-config/lua/plugins/git.lua
T
naps62 26643d8ba8 feat(git): add gitsigns hunk keymaps, drop diffview
Gitsigns was configured with sign glyphs and no bindings at all, so
hunks were visible but not navigable — the main thing you do when
reading back what an agent changed. Adds ]c/[c, preview, reset, blame
and diffthis, buffer-local on attach.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-17 13:00:47 +00:00

53 lines
1.4 KiB
Lua

return {
{
"NeogitOrg/neogit",
cmd = "Neogit",
dependencies = {
"nvim-lua/plenary.nvim", -- required
"ibhagwan/fzf-lua", -- optional - picker
},
config = true,
keys = {
{ "<leader>g", "<cmd>Neogit<CR>", desc = "Neogit" },
},
},
{
"lewis6991/gitsigns.nvim",
opts = function(_, opts)
opts.on_attach = function(bufnr)
local gs = require "gitsigns"
local function map(mode, lhs, rhs, desc)
vim.keymap.set(mode, lhs, rhs, { buffer = bufnr, desc = "Gitsigns " .. desc })
end
-- ]c/[c belong to vim's builtin diff navigation while the window is in diff mode
map("n", "]c", function()
if vim.wo.diff then
vim.cmd.normal { "]c", bang = true }
else
gs.nav_hunk "next"
end
end, "next hunk")
map("n", "[c", function()
if vim.wo.diff then
vim.cmd.normal { "[c", bang = true }
else
gs.nav_hunk "prev"
end
end, "prev hunk")
map("n", "<leader>hp", gs.preview_hunk, "preview hunk")
map("n", "<leader>hb", gs.blame_line, "blame line")
map("n", "<leader>hd", gs.diffthis, "diff against index")
map({ "n", "v" }, "<leader>hr", gs.reset_hunk, "reset hunk")
end
return opts
end,
},
{ "akinsho/git-conflict.nvim", event = "VeryLazy", config = true },
}