60 lines
1.8 KiB
Nix
60 lines
1.8 KiB
Nix
{ nix2lua, vim, lib, ... }:
|
|
|
|
with nix2lua.lib;
|
|
|
|
let
|
|
defaultKeymaps = [
|
|
{ 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"; }
|
|
];
|
|
in
|
|
|
|
{ configs ? { }
|
|
, keymaps ? defaultKeymaps
|
|
, extraKeymaps ? [ ]
|
|
}:
|
|
|
|
let
|
|
bufferedKeymaps = map
|
|
(args: lib.recursiveUpdate args { opts.buffer = var "bufnr"; })
|
|
(keymaps ++ extraKeymaps);
|
|
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";
|
|
}))
|
|
)
|
|
];
|
|
|
|
}
|