mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 00:25:42 +02:00
plugins/spider: add plugin + test (#330)
This commit is contained in:
parent
a9e3ff3f73
commit
3b1df35a8c
3 changed files with 102 additions and 0 deletions
|
@ -87,6 +87,7 @@
|
|||
./utils/project-nvim.nix
|
||||
./utils/presence-nvim.nix
|
||||
./utils/specs.nix
|
||||
./utils/spider.nix
|
||||
./utils/startify.nix
|
||||
./utils/surround.nix
|
||||
./utils/tmux-navigator.nix
|
||||
|
|
79
plugins/utils/spider.nix
Normal file
79
plugins/utils/spider.nix
Normal file
|
@ -0,0 +1,79 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
pluginName = "spider";
|
||||
cfg = config.plugins.${pluginName};
|
||||
helpers = import ../helpers.nix {inherit lib;};
|
||||
in {
|
||||
options.plugins.${pluginName} =
|
||||
helpers.extraOptionsOptions
|
||||
// {
|
||||
enable = mkEnableOption pluginName;
|
||||
|
||||
package = helpers.mkPackageOption pluginName pkgs.vimPlugins.nvim-spider;
|
||||
|
||||
skipInsignificantPunctuation =
|
||||
helpers.defaultNullOpts.mkBool true "Whether to skip unsignificant punctuation.";
|
||||
|
||||
keymaps = {
|
||||
silent = mkOption {
|
||||
type = types.bool;
|
||||
description = "Whether ${pluginName} keymaps should be silent.";
|
||||
default = false;
|
||||
};
|
||||
|
||||
motions = mkOption {
|
||||
type = types.attrsOf types.str;
|
||||
description = ''
|
||||
Mappings for spider motions.
|
||||
The keys are the motion and the values are the keyboard shortcuts.
|
||||
The shortcut might not necessarily be the same as the motion name.
|
||||
'';
|
||||
default = {};
|
||||
example = {
|
||||
w = "w";
|
||||
e = "e";
|
||||
b = "b";
|
||||
g = "ge";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = let
|
||||
setupOptions =
|
||||
{
|
||||
inherit (cfg) skipInsignificantPunctuation;
|
||||
}
|
||||
// cfg.extraOptions;
|
||||
|
||||
mappings =
|
||||
mapAttrs'
|
||||
(motion: key: {
|
||||
name = key;
|
||||
value = {
|
||||
action = "function() require('spider').motion('${motion}') end";
|
||||
lua = true;
|
||||
inherit (cfg.keymaps) silent;
|
||||
desc = "Spider-${motion}";
|
||||
};
|
||||
})
|
||||
cfg.keymaps.motions;
|
||||
in
|
||||
mkIf cfg.enable {
|
||||
extraPlugins = [cfg.package];
|
||||
|
||||
maps =
|
||||
genAttrs
|
||||
["normal" "operator" "visualOnly"]
|
||||
(mode: mappings);
|
||||
|
||||
extraConfigLua = ''
|
||||
require("${pluginName}").setup(${helpers.toLuaObject setupOptions})
|
||||
'';
|
||||
};
|
||||
}
|
22
tests/test-sources/plugins/utils/spider.nix
Normal file
22
tests/test-sources/plugins/utils/spider.nix
Normal file
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
empty = {
|
||||
plugins.spider.enable = true;
|
||||
};
|
||||
|
||||
example = {
|
||||
plugins.spider = {
|
||||
enable = true;
|
||||
|
||||
skipInsignificantPunctuation = true;
|
||||
keymaps = {
|
||||
silent = true;
|
||||
motions = {
|
||||
w = "w";
|
||||
e = "e";
|
||||
b = "b";
|
||||
g = "ge";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue