mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-20 16:15:43 +02:00
80 lines
1.8 KiB
Nix
80 lines
1.8 KiB
Nix
{
|
|
lib,
|
|
helpers,
|
|
config,
|
|
pkgs,
|
|
...
|
|
}:
|
|
with lib;
|
|
let
|
|
pluginName = "spider";
|
|
cfg = config.plugins.${pluginName};
|
|
in
|
|
{
|
|
options.plugins.${pluginName} = lib.nixvim.neovim-plugin.extraOptionsOptions // {
|
|
enable = mkEnableOption pluginName;
|
|
|
|
package = lib.mkPackageOption pkgs pluginName {
|
|
default = [
|
|
"vimPlugins"
|
|
"nvim-spider"
|
|
];
|
|
};
|
|
|
|
skipInsignificantPunctuation = helpers.defaultNullOpts.mkBool true "Whether to skip insignificant 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";
|
|
ge = "ge";
|
|
};
|
|
};
|
|
};
|
|
};
|
|
|
|
config =
|
|
let
|
|
setupOptions = {
|
|
inherit (cfg) skipInsignificantPunctuation;
|
|
} // cfg.extraOptions;
|
|
|
|
mappings = mapAttrsToList (motion: key: {
|
|
mode = [
|
|
"n"
|
|
"o"
|
|
"x"
|
|
];
|
|
inherit key;
|
|
action.__raw = "function() require('spider').motion('${motion}') end";
|
|
options = {
|
|
inherit (cfg.keymaps) silent;
|
|
desc = "Spider-${motion}";
|
|
};
|
|
}) cfg.keymaps.motions;
|
|
in
|
|
mkIf cfg.enable {
|
|
extraPlugins = [ cfg.package ];
|
|
|
|
keymaps = mappings;
|
|
|
|
extraConfigLua = ''
|
|
require("${pluginName}").setup(${lib.nixvim.toLuaObject setupOptions})
|
|
'';
|
|
};
|
|
}
|