2023-04-16 11:09:59 +02:00
|
|
|
{
|
|
|
|
lib,
|
2023-11-06 15:04:08 +01:00
|
|
|
helpers,
|
|
|
|
config,
|
|
|
|
pkgs,
|
2023-04-16 11:09:59 +02:00
|
|
|
...
|
|
|
|
}:
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
pluginName = "spider";
|
|
|
|
cfg = config.plugins.${pluginName};
|
|
|
|
in
|
|
|
|
{
|
2024-12-22 09:58:27 +00:00
|
|
|
options.plugins.${pluginName} = lib.nixvim.plugins.neovim.extraOptionsOptions // {
|
2023-04-16 11:09:59 +02:00
|
|
|
enable = mkEnableOption pluginName;
|
|
|
|
|
2024-09-04 22:00:43 +01:00
|
|
|
package = lib.mkPackageOption pkgs pluginName {
|
|
|
|
default = [
|
|
|
|
"vimPlugins"
|
|
|
|
"nvim-spider"
|
|
|
|
];
|
|
|
|
};
|
2023-04-16 11:09:59 +02:00
|
|
|
|
2024-03-07 19:44:13 +01:00
|
|
|
skipInsignificantPunctuation = helpers.defaultNullOpts.mkBool true "Whether to skip insignificant punctuation.";
|
2023-04-16 11:09:59 +02:00
|
|
|
|
|
|
|
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";
|
2023-11-02 15:11:21 +01:00
|
|
|
ge = "ge";
|
2023-04-16 11:09:59 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2024-05-05 19:39:35 +02:00
|
|
|
};
|
2023-04-16 11:09:59 +02:00
|
|
|
|
|
|
|
config =
|
|
|
|
let
|
|
|
|
setupOptions = {
|
|
|
|
inherit (cfg) skipInsignificantPunctuation;
|
|
|
|
} // cfg.extraOptions;
|
|
|
|
|
2023-09-15 14:35:13 +02:00
|
|
|
mappings = mapAttrsToList (motion: key: {
|
|
|
|
mode = [
|
|
|
|
"n"
|
|
|
|
"o"
|
|
|
|
"x"
|
|
|
|
];
|
|
|
|
inherit key;
|
2024-02-03 17:42:24 +01:00
|
|
|
action.__raw = "function() require('spider').motion('${motion}') end";
|
2023-09-15 14:35:13 +02:00
|
|
|
options = {
|
|
|
|
inherit (cfg.keymaps) silent;
|
|
|
|
desc = "Spider-${motion}";
|
|
|
|
};
|
2023-04-16 11:09:59 +02:00
|
|
|
}) cfg.keymaps.motions;
|
|
|
|
in
|
|
|
|
mkIf cfg.enable {
|
|
|
|
extraPlugins = [ cfg.package ];
|
2025-04-11 13:00:34 +02:00
|
|
|
extraLuaPackages = luaPkgs: [ luaPkgs.luautf8 ];
|
2023-04-16 11:09:59 +02:00
|
|
|
|
2023-09-15 14:35:13 +02:00
|
|
|
keymaps = mappings;
|
2023-04-16 11:09:59 +02:00
|
|
|
|
|
|
|
extraConfigLua = ''
|
2024-12-15 20:32:14 +01:00
|
|
|
require("${pluginName}").setup(${lib.nixvim.toLuaObject setupOptions})
|
2023-04-16 11:09:59 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
}
|