-
-
Notifications
You must be signed in to change notification settings - Fork 213
/
spider.nix
75 lines (67 loc) · 1.74 KB
/
spider.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
{
lib,
helpers,
config,
pkgs,
...
}:
with lib;
let
pluginName = "spider";
cfg = config.plugins.${pluginName};
in
{
options.plugins.${pluginName} = helpers.neovim-plugin.extraOptionsOptions // {
enable = mkEnableOption pluginName;
package = helpers.mkPluginPackageOption pluginName pkgs.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(${helpers.toLuaObject setupOptions})
'';
};
}