42 lines
968 B
Nix
42 lines
968 B
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
let cfg = config.plugins.gitsigns; in
|
|
|
|
{
|
|
options.plugins.gitsigns = with lib; {
|
|
enable = mkEnableOption "gitsigns-nvim";
|
|
|
|
package = mkPackageOption pkgs.vimPlugins "gitsigns-nvim" { };
|
|
|
|
settings = mkOption {
|
|
type = types.attrs;
|
|
default = { };
|
|
};
|
|
|
|
keymap.set = mkOption {
|
|
type = with types; listOf keymap;
|
|
default = [ ];
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
fn.gitsigns-nvim-on-attach = lib.mkIf (cfg.keymap.set != [ ]) {
|
|
args = [ "bufnr" ];
|
|
content = { bufnr }: {
|
|
vim.keymap.set = map (attrs: attrs // { buffer = bufnr; }) cfg.keymap.set;
|
|
};
|
|
};
|
|
|
|
plugin.gitsigns-nvim = {
|
|
name = "gitsigns";
|
|
varName = "gs";
|
|
package = cfg.package;
|
|
setupSettings = lib.mkMerge [
|
|
cfg.settings
|
|
(lib.mkIf (cfg.keymap.set != [ ]) {
|
|
on_attach = config.fn.gitsigns-nvim-on-attach.lambda;
|
|
})
|
|
];
|
|
};
|
|
};
|
|
}
|