summaryrefslogtreecommitdiff
path: root/init.lua
diff options
context:
space:
mode:
authorChris Patti <feoh@feoh.org>2023-09-06 16:58:20 -0400
committerGitHub <noreply@github.com>2023-09-06 16:58:20 -0400
commitc010cc71d59390bb1e95790c316e76f9bc5fcb62 (patch)
tree0289a2f7072a95af6ce922c4a32bb0d0b03381e1 /init.lua
parent304b2445cf21625a23ce27bb62903d2ea2517565 (diff)
parent38a0f0323196c406e6e81d52052b2ac213bfe709 (diff)
Merge pull request #406 from gangelop/git-keymaps
Revert gitsigns keymaps but fix vimdiff and fugitive conflict
Diffstat (limited to 'init.lua')
-rw-r--r--init.lua17
1 files changed, 14 insertions, 3 deletions
diff --git a/init.lua b/init.lua
index be65154..834baf4 100644
--- a/init.lua
+++ b/init.lua
@@ -124,9 +124,20 @@ require('lazy').setup({
changedelete = { text = '~' },
},
on_attach = function(bufnr)
- vim.keymap.set('n', '<leader>gp', require('gitsigns').prev_hunk, { buffer = bufnr, desc = '[G]o to [P]revious Hunk' })
- vim.keymap.set('n', '<leader>gn', require('gitsigns').next_hunk, { buffer = bufnr, desc = '[G]o to [N]ext Hunk' })
- vim.keymap.set('n', '<leader>ph', require('gitsigns').preview_hunk, { buffer = bufnr, desc = '[P]review [H]unk' })
+ vim.keymap.set('n', '<leader>hp', require('gitsigns').preview_hunk, { buffer = bufnr, desc = 'Preview git hunk' })
+
+ -- don't override the built-in and fugitive keymaps
+ local gs = package.loaded.gitsigns
+ vim.keymap.set({'n', 'v'}, ']c', function()
+ if vim.wo.diff then return ']c' end
+ vim.schedule(function() gs.next_hunk() end)
+ return '<Ignore>'
+ end, {expr=true, buffer = bufnr, desc = "Jump to next hunk"})
+ vim.keymap.set({'n', 'v'}, '[c', function()
+ if vim.wo.diff then return '[c' end
+ vim.schedule(function() gs.prev_hunk() end)
+ return '<Ignore>'
+ end, {expr=true, buffer = bufnr, desc = "Jump to previous hunk"})
end,
},
},