nixvim/config/gitsign.nix

70 lines
1.3 KiB
Nix
Raw Normal View History

2024-08-20 05:43:03 +00:00
{ helpers, ... }:
{
plugins.gitsigns = {
enable = true;
};
keymaps = [
# Navigate through hunks
{
mode = [ "n" ];
key = "]c";
action = helpers.mkRaw ''
function()
if vim.wo.diff then
vim.cmd.normal({']c', bang = true})
else
require("gitsigns").nav_hunk('next')
end
end
'';
}
{
mode = [ "n" ];
key = "[c";
action = helpers.mkRaw ''
function()
if vim.wo.diff then
vim.cmd.normal({'[c', bang = true})
else
require("gitsigns").nav_hunk('prev')
end
end
'';
}
{
mode = [ "v" ];
key = "<leader>hs";
action = helpers.mkRaw ''
function()
require("gitsigns").stage_hunk({ vim.fn.line("."), vim.fn.line("v") })
end
'';
options = {
desc = "Stage Hunk";
};
}
{
mode = [ "n" ];
key = "<leader>hu";
action = helpers.mkRaw ''
require("gitsigns").undo_stage_hunk
'';
options = {
desc = "Undo Stage Hunk";
};
}
{
mode = [ "n" ];
key = "<leader>hp";
action = helpers.mkRaw ''
require("gitsigns").preview_hunk
'';
options = {
desc = "Preview Hunk";
};
}
];
}