Compare commits

..

1 commit

Author SHA1 Message Date
Bruno BELANYI 530badbabd home: vim: git: use lua in mappings
All checks were successful
ci/woodpecker/push/check Pipeline was successful
I thought the partial staging feature had broken, but it looks to be
unrelated [1].

[1]: https://github.com/lewis6991/gitsigns.nvim/issues/1088
2024-07-12 20:00:48 +01:00

View file

@ -10,20 +10,6 @@ local function make_visual(f)
end
end
local function nav_hunk(dir)
return function()
if vim.wo.diff then
local map = {
prev = "[c",
next = "]c",
}
vim.cmd.normal({ map[dir], bang = true })
else
gitsigns.nav_hunk(dir)
end
end
end
gitsigns.setup({
current_line_blame_opts = {
-- Show the blame quickly
@ -33,8 +19,8 @@ gitsigns.setup({
local keys = {
-- Navigation
["[c"] = { nav_hunk("prev"), "Previous hunk/diff" },
["]c"] = { nav_hunk("next"), "Next hunk/diff" },
["[c"] = { "&diff ? '[c' : '<cmd>Gitsigns prev_hunk<CR>'", "Previous hunk/diff", expr = true },
["]c"] = { "&diff ? ']c' : '<cmd>Gitsigns next_hunk<CR>'", "Next hunk/diff", expr = true },
-- Commands
["<leader>g"] = {
@ -72,7 +58,7 @@ local visual = {
p = { gitsigns.preview_hunk, "Preview selection" },
r = { make_visual(gitsigns.reset_hunk), "Restore selection" },
s = { make_visual(gitsigns.stage_hunk), "Stage selection" },
u = { gitsigns.undo_stage_hunk, "Undo stage selection" },
u = { gitsigns.undo_stage_hunk, "Undo stage hunk" },
},
}