nixeovim/modules/plugins/gitsigns.nix

43 lines
968 B
Nix
Raw Normal View History

2024-05-01 01:50:34 +03:00
{ 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;
2024-05-06 12:32:33 +03:00
default = [ ];
2024-05-01 01:50:34 +03:00
};
};
config = lib.mkIf cfg.enable {
2024-05-06 12:32:33 +03:00
fn.gitsigns-nvim-on-attach = lib.mkIf (cfg.keymap.set != [ ]) {
2024-05-01 01:50:34 +03:00
args = [ "bufnr" ];
content = { bufnr }: {
2024-05-01 01:50:34 +03:00
vim.keymap.set = map (attrs: attrs // { buffer = bufnr; }) cfg.keymap.set;
};
};
plugin.gitsigns-nvim = {
name = "gitsigns";
varName = "gs";
package = cfg.package;
2024-05-06 12:32:33 +03:00
setupSettings = lib.mkMerge [
cfg.settings
(lib.mkIf (cfg.keymap.set != [ ]) {
on_attach = config.fn.gitsigns-nvim-on-attach.lambda;
})
];
2024-05-01 01:50:34 +03:00
};
};
}