diff --git a/plugins/default.nix b/plugins/default.nix index 1e20a842..454ffb5b 100644 --- a/plugins/default.nix +++ b/plugins/default.nix @@ -42,6 +42,7 @@ ./git/git-worktree.nix ./git/gitblame.nix ./git/gitgutter.nix + ./git/gitignore.nix ./git/gitlinker.nix ./git/gitmessenger.nix ./git/gitsigns diff --git a/plugins/git/gitignore.nix b/plugins/git/gitignore.nix new file mode 100644 index 00000000..f091f10c --- /dev/null +++ b/plugins/git/gitignore.nix @@ -0,0 +1,68 @@ +{ + lib, + helpers, + config, + pkgs, + ... +}: +with lib; +# We use `mkVimPlugin` to avoid having a `settings` option. +# Indeed, this plugin is not configurable in the common sense (no `setup` function). + helpers.vim-plugin.mkVimPlugin config { + name = "gitignore"; + originalName = "gitignore.nvim"; + defaultPackage = pkgs.vimPlugins.gitignore-nvim; + + maintainers = [maintainers.GaetanLepage]; + + extraOptions = { + keymap = mkOption { + type = with types; + nullOr + ( + either + str + (submodule { + options = { + key = mkOption { + type = str; + description = "The key to map."; + example = "gi"; + }; + + mode = helpers.keymaps.mkModeOption "n"; + + options = helpers.keymaps.mapConfigOptions; + }; + }) + ); + default = null; + description = '' + Keyboard shortcut for the `gitignore.generate` command. + Can be: + - A string: which key to bind + - An attrs: if you want to customize the mode and/or the options of the keymap + (`desc`, `silent`, ...) + ''; + example = "gi"; + }; + }; + + extraConfig = cfg: { + keymaps = + optional (cfg.keymap != null) + ( + ( + if isString cfg.keymap + then { + mode = "n"; + key = cfg.keymap; + } + else cfg.keymap + ) + // { + action.__raw = "require('gitignore').generate"; + } + ); + }; + } diff --git a/tests/test-sources/plugins/git/gitignore.nix b/tests/test-sources/plugins/git/gitignore.nix new file mode 100644 index 00000000..7e58e730 --- /dev/null +++ b/tests/test-sources/plugins/git/gitignore.nix @@ -0,0 +1,13 @@ +{ + empty = { + plugins.gitignore.enable = true; + }; + + example = { + plugins.gitignore = { + enable = true; + + keymap = "gi"; + }; + }; +}