nixeovim/modules/plugins/gitsigns.nix
2024-05-01 02:01:47 +03:00

38 lines
840 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;
};
};
config = lib.mkIf cfg.enable {
fn.gitsigns-nvim-on-attach = {
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 = cfg.settings // {
on_attach = config.fn.gitsigns-nvim-on-attach.lambda;
};
};
};
}