From 883703328d32fe52533d14a659602e06efd294ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=A9tan=20Lepage?= <33058747+GaetanLepage@users.noreply.github.com> Date: Tue, 14 Mar 2023 15:21:35 +0100 Subject: [PATCH] plugins/vim-bbye: init + tests (#248) --- plugins/default.nix | 1 + plugins/utils/vim-bbye.nix | 52 ++++++++++++++++++++++++++++++++++++++ tests/plugins/vim-bbye.nix | 18 +++++++++++++ 3 files changed, 71 insertions(+) create mode 100644 plugins/utils/vim-bbye.nix create mode 100644 tests/plugins/vim-bbye.nix diff --git a/plugins/default.nix b/plugins/default.nix index 7e02130d..4b98df42 100644 --- a/plugins/default.nix +++ b/plugins/default.nix @@ -76,6 +76,7 @@ ./utils/surround.nix ./utils/todo-comments.nix ./utils/undotree.nix + ./utils/vim-bbye.nix ./utils/vim-matchup.nix ./utils/dashboard.nix ./utils/emmet.nix diff --git a/plugins/utils/vim-bbye.nix b/plugins/utils/vim-bbye.nix new file mode 100644 index 00000000..cb718f35 --- /dev/null +++ b/plugins/utils/vim-bbye.nix @@ -0,0 +1,52 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; let + cfg = config.plugins.vim-bbye; + helpers = import ../helpers.nix {inherit lib;}; +in { + options.plugins.vim-bbye = { + enable = mkEnableOption "vim-bbye"; + + package = helpers.mkPackageOption "vim-bbye" pkgs.vimPlugins.vim-bbye; + + keymapsSilent = mkOption { + type = types.bool; + description = "Whether vim-bbye keymaps should be silent."; + default = false; + }; + + keymaps = { + bdelete = helpers.mkNullOrOption types.str '' + Keymap for deleting the current buffer."; + ''; + + bwipeout = helpers.mkNullOrOption types.str '' + Keymap for completely deleting the current buffer."; + ''; + }; + }; + + config = mkIf cfg.enable { + extraPlugins = [cfg.package]; + + maps.normal = with cfg.keymaps; + (optionalAttrs (!isNull bdelete) + { + ${bdelete} = { + action = ":Bdelete"; + silent = cfg.keymapsSilent; + }; + }) + // (optionalAttrs (!isNull bwipeout) + { + ${bwipeout} = { + action = ":Bwipeout"; + silent = cfg.keymapsSilent; + }; + }); + }; +} diff --git a/tests/plugins/vim-bbye.nix b/tests/plugins/vim-bbye.nix new file mode 100644 index 00000000..6d6a8c06 --- /dev/null +++ b/tests/plugins/vim-bbye.nix @@ -0,0 +1,18 @@ +{ + empty = { + plugins.vim-bbye.enable = true; + }; + + test = { + plugins.vim-bbye = { + enable = true; + + keymapsSilent = false; + + keymaps = { + bdelete = ""; + bwipeout = ""; + }; + }; + }; +}