From 269d592ea82822c4b138b20532a4c9e8f9720851 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Sat, 1 Jul 2023 08:57:44 +0200 Subject: [PATCH] plugins/quickmath: init + test --- plugins/default.nix | 1 + plugins/utils/quickmath.nix | 37 +++++++++++++++++++ .../test-sources/plugins/utils/quickmath.nix | 16 ++++++++ 3 files changed, 54 insertions(+) create mode 100644 plugins/utils/quickmath.nix create mode 100644 tests/test-sources/plugins/utils/quickmath.nix diff --git a/plugins/default.nix b/plugins/default.nix index 8641b8f4..36333283 100644 --- a/plugins/default.nix +++ b/plugins/default.nix @@ -107,6 +107,7 @@ ./utils/oil.nix ./utils/project-nvim.nix ./utils/presence-nvim.nix + ./utils/quickmath.nix ./utils/specs.nix ./utils/spider.nix ./utils/startify.nix diff --git a/plugins/utils/quickmath.nix b/plugins/utils/quickmath.nix new file mode 100644 index 00000000..6fde8568 --- /dev/null +++ b/plugins/utils/quickmath.nix @@ -0,0 +1,37 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; let + cfg = config.plugins.quickmath; + helpers = import ../helpers.nix {inherit lib;}; +in { + options.plugins.quickmath = { + enable = mkEnableOption "quickmath.nvim"; + + package = helpers.mkPackageOption "quickmath.nvim" pkgs.vimPlugins.quickmath-nvim; + + keymap = { + key = helpers.mkNullOrOption types.str "Keymap to run the `:Quickmath` command."; + + silent = mkOption { + type = types.bool; + description = "Whether the quickmath keymap should be silent."; + default = false; + }; + }; + }; + + config = mkIf cfg.enable { + extraPlugins = [cfg.package]; + + maps.normal = mkIf (cfg.keymap.key != null) { + ${cfg.keymap.key} = { + action = ":Quickmath"; + inherit (cfg.keymap) silent; + }; + }; + }; +} diff --git a/tests/test-sources/plugins/utils/quickmath.nix b/tests/test-sources/plugins/utils/quickmath.nix new file mode 100644 index 00000000..8c74259e --- /dev/null +++ b/tests/test-sources/plugins/utils/quickmath.nix @@ -0,0 +1,16 @@ +{ + empty = { + plugins.quickmath.enable = true; + }; + + example = { + plugins.quickmath = { + enable = true; + + keymap = { + key = "q"; + silent = true; + }; + }; + }; +}