commit 8234ae978933f1028409928ef11129ee497fbf7d
parent 3047461dc8202bd199a2eefa4cdcf46d3aa0214a
Author: pyratebeard <root@pyratebeard.net>
Date: Fri, 5 Sep 2025 10:29:44 +0100
feat(neovim): add chunk navigation to gitsigns plugin
Diffstat:
1 file changed, 25 insertions(+), 0 deletions(-)
diff --git a/neovim/.config/nvim/lua/plugins/gitsigns.lua b/neovim/.config/nvim/lua/plugins/gitsigns.lua
@@ -20,6 +20,31 @@ return {
interval = 1000,
},
attach_to_untracked = false,
+ on_attach = function(bufnr)
+ local gitsigns = require("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', ']c', function()
+ if vim.wo.diff then
+ vim.cmd.normal({']c', bang = true})
+ else
+ gitsigns.nav_hunk('next')
+ end
+ end)
+
+ map('n', '[c', function()
+ if vim.wo.diff then
+ vim.cmd.normal({'[c', bang = true})
+ else
+ gitsigns.nav_hunk('prev')
+ end
+ end)
+ end
})
-- if pcall(require, "scrollbar") then
-- require("scrollbar.handlers.gitsigns").setup()