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>
This commit is contained in:
naps62
2026-08-17 13:00:47 +00:00
parent 98dc1ba7f2
commit 26643d8ba8
2 changed files with 33 additions and 13 deletions
-1
View File
@@ -10,7 +10,6 @@
"cmp-nvim-lua": { "branch": "main", "commit": "e3a22cb071eb9d6508a156306b102c45cd2d573d" },
"cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" },
"conform.nvim": { "branch": "master", "commit": "619363c30309d29ffa631e67c8183f2a72caa373" },
"diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" },
"friendly-snippets": { "branch": "main", "commit": "6cd7280adead7f586db6fccbd15d2cac7e2188b9" },
"fzf-lua": { "branch": "main", "commit": "988416cc782dfe28bff3f0da9b8c943b236cd86a" },
"git-conflict.nvim": { "branch": "main", "commit": "a1badcd070d176172940eb55d9d59029dad1c5a6" },
+33 -12
View File
@@ -4,7 +4,6 @@ return {
cmd = "Neogit",
dependencies = {
"nvim-lua/plenary.nvim", -- required
"sindrets/diffview.nvim", -- optional - Diff integration
"ibhagwan/fzf-lua", -- optional - picker
},
config = true,
@@ -14,17 +13,39 @@ return {
},
{
"sindrets/diffview.nvim",
event = "VeryLazy",
dependencies = "nvim-lua/plenary.nvim",
opts = {
enhanced_diff_hl = true,
file_panel = {
win_config = {
width = 25,
},
},
},
"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 },