2024-04-20 23:05:33 +03:00
|
|
|
{ nix2lua, vim, lib, ... }:
|
|
|
|
|
|
|
|
with nix2lua.lib;
|
|
|
|
|
2024-04-21 11:46:13 +03:00
|
|
|
let
|
|
|
|
defaultKeymaps = [
|
2024-04-20 23:05:33 +03:00
|
|
|
{ mode = "n"; bind = "]h"; command = raw "next_hunk"; }
|
|
|
|
{ mode = "n"; bind = "[h"; command = raw "prev_hunk"; }
|
|
|
|
{ mode = "n"; bind = "<leader>gs"; command = raw "gs.stage_hunk"; }
|
|
|
|
{ mode = "n"; bind = "<leader>gr"; command = raw "gs.reset_hunk"; }
|
|
|
|
{ mode = "n"; bind = "<leader>gu"; command = raw "gs.undo_stage_hunk"; }
|
|
|
|
{ mode = "n"; bind = "<leader>gp"; command = raw "gs.preview_hunk"; }
|
|
|
|
{ mode = "n"; bind = "<leader>gb"; command = lambda0 (call "gs.blame_line" { full = true; }); }
|
|
|
|
{ mode = "n"; bind = "<leader>gd"; command = raw "gs.diffthis"; }
|
|
|
|
{ mode = "n"; bind = "<leader>gD"; command = lambda0 (call "gs.diffthis" "~"); }
|
|
|
|
{ mode = "n"; bind = "<leader>gtb"; command = raw "gs.toggle_current_line_blame"; }
|
|
|
|
{ mode = "n"; bind = "<leader>gtd"; command = raw "gs.toggle_deleted"; }
|
2024-04-21 11:46:13 +03:00
|
|
|
];
|
|
|
|
in
|
|
|
|
|
|
|
|
{ configs ? { }
|
|
|
|
, keymaps ? defaultKeymaps
|
|
|
|
, extraKeymaps ? [ ]
|
2024-04-20 23:05:33 +03:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2024-04-21 11:46:13 +03:00
|
|
|
bufferedKeymaps = map
|
|
|
|
(args: lib.recursiveUpdate args { opts.buffer = var "bufnr"; })
|
|
|
|
(keymaps ++ extraKeymaps);
|
2024-04-20 23:05:33 +03:00
|
|
|
in
|
|
|
|
{
|
|
|
|
gitsigns-nvim = [
|
|
|
|
(local (func "on_attach" [ "bufnr" ] (
|
|
|
|
[
|
|
|
|
(local (set "gs" (var "package.loaded.gitsigns")))
|
|
|
|
|
|
|
|
(local (func0 "next_hunk"
|
|
|
|
(ifelse (var "vim.wo.diff")
|
|
|
|
(call1 "vim.cmd.normal" [ "]h" (nf "bang" true) ])
|
|
|
|
(call1 "gs.nav_hunk" "next")
|
|
|
|
)
|
|
|
|
))
|
|
|
|
(local (func0 "prev_hunk"
|
|
|
|
(ifelse (var "vim.wo.diff")
|
|
|
|
(call1 "vim.cmd.normal" [ "[h" (nf "bang" true) ])
|
|
|
|
(call1 "gs.nav_hunk" "prev"))
|
|
|
|
))
|
|
|
|
]
|
|
|
|
++ map vim.keymap.set bufferedKeymaps
|
|
|
|
)))
|
|
|
|
|
|
|
|
(pipe1
|
|
|
|
(require "gitsigns")
|
|
|
|
(call "setup" (configs // {
|
|
|
|
on_attach = var "on_attach";
|
|
|
|
}))
|
|
|
|
)
|
|
|
|
];
|
|
|
|
|
|
|
|
}
|