modules: add gitsigns

This commit is contained in:
Dmitriy Pleshevskiy 2024-05-01 01:50:34 +03:00
parent 4cc9de194f
commit 238e4bf68e
Signed by: pleshevskiy
GPG key ID: 17041163DA10A9A2
3 changed files with 39 additions and 1 deletions

View file

@ -129,7 +129,6 @@ let
genConfig = mkOption {
type = types.attrs;
readOnly = true;
internal = true;
};
};

View file

@ -15,6 +15,7 @@
./modules/plugins/style/neoformat.nix
./modules/plugins/navigation/telescope.nix
./modules/plugins/navigation/nvim-tree.nix
./modules/plugins/gitsigns.nix
##################################################
(pkgs.path + "/nixos/modules/misc/assertions.nix")

View file

@ -0,0 +1,38 @@
{ 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" ];
settings = { 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;
};
};
};
}