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:
@@ -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
@@ -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 },
|
||||
|
||||
Reference in New Issue
Block a user