From cb61e12bbac08fc7fd2c672974ccf2d12cdcf236 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Sun, 15 Dec 2024 18:04:49 +0100 Subject: [PATCH] plugins/easyescape: switch to mkVimPlugin and add options --- plugins/by-name/easyescape/default.nix | 48 +++++++++++++------ .../plugins/by-name/easyescape/default.nix | 25 ++++++++++ 2 files changed, 58 insertions(+), 15 deletions(-) diff --git a/plugins/by-name/easyescape/default.nix b/plugins/by-name/easyescape/default.nix index 8f8a2c6d94..599c8e0705 100644 --- a/plugins/by-name/easyescape/default.nix +++ b/plugins/by-name/easyescape/default.nix @@ -1,26 +1,44 @@ { lib, - helpers, - config, - pkgs, ... }: -with lib; let - cfg = config.plugins.easyescape; + inherit (lib.nixvim) defaultNullOpts; + inherit (lib) types; in -{ - options = { - plugins.easyescape = { - enable = mkEnableOption "easyescape"; +lib.nixvim.vim-plugin.mkVimPlugin { + name = "easyescape"; + packPathName = "vim-easyescape"; + package = "vim-easyescape"; + globalPrefix = "easyescape_"; + + maintainers = [ lib.maintainers.GaetanLepage ]; - package = lib.mkPackageOption pkgs "easyescape" { - default = [ - "vimPlugins" - "vim-easyescape" - ]; + settingsOptions = { + chars = defaultNullOpts.mkAttrsOf' { + type = types.ints.unsigned; + pluginDefault = { + j = 1; + k = 1; }; + example = { + j = 2; + }; + description = '' + Which keys can be used to escape insert mode and how many times they need to be pressed. + ''; }; + + timeout = defaultNullOpts.mkUnsignedInt 100 '' + The unit of timeout is in ms. + + A very small timeout makes an input of real `jk` or `kj` possible (Python3 is required for + this feature)! + ''; + }; + + settingsExample = { + chars.j = 2; + timeout = 2000; }; - config = mkIf cfg.enable { extraPlugins = [ cfg.package ]; }; } diff --git a/tests/test-sources/plugins/by-name/easyescape/default.nix b/tests/test-sources/plugins/by-name/easyescape/default.nix index 31552f7234..b09b83823a 100644 --- a/tests/test-sources/plugins/by-name/easyescape/default.nix +++ b/tests/test-sources/plugins/by-name/easyescape/default.nix @@ -2,4 +2,29 @@ empty = { plugins.easyescape.enable = true; }; + + defaults = { + plugins.easyescape = { + enable = true; + + settings = { + chars = { + j = 1; + k = 1; + }; + timeout = 100; + }; + }; + }; + + example = { + plugins.easyescape = { + enable = true; + + settings = { + chars.j = 2; + timeout = 2000; + }; + }; + }; }