Skip to content

Commit 8ae9e4d

Browse files
committed
plugins/mini: migrate to mkNeovimPlugin
1 parent ac4629e commit 8ae9e4d

File tree

1 file changed

+69
-30
lines changed

1 file changed

+69
-30
lines changed

plugins/utils/mini.nix

Lines changed: 69 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,90 @@
11
{
22
lib,
3-
helpers,
4-
config,
5-
pkgs,
63
...
74
}:
8-
with lib;
9-
let
10-
cfg = config.plugins.mini;
11-
in
12-
{
13-
options.plugins.mini = {
14-
enable = mkEnableOption "mini.nvim";
5+
lib.nixvim.neovim-plugin.mkNeovimPlugin {
6+
name = "mini";
7+
originalName = "mini.nvim";
158

16-
package = lib.mkPackageOption pkgs "mini.nvim" {
17-
default = [
18-
"vimPlugins"
19-
"mini-nvim"
20-
];
21-
};
9+
maintainers = [ lib.maintainers.khaneliman ];
10+
11+
package = "mini-nvim";
2212

23-
modules = mkOption {
24-
type = with types; attrsOf attrs;
13+
extraOptions = {
14+
modules = lib.mkOption {
15+
type = with lib.types; attrsOf (attrsOf anything);
2516
default = { };
2617
description = ''
2718
Enable and configure the mini modules.
28-
The keys are the names of the modules (without the `mini.` prefix).
29-
The value is an attrs of configuration options for the module.
30-
Leave the attrs empty to use the module's default configuration.
19+
20+
The attr name represent mini's module names, without the `"mini."` prefix.
21+
The attr value is an attrset of options provided to the module's `setup` function.
22+
23+
See the [plugin documentation] for available modules to configure:
24+
25+
[plugin documentation]: https://github.com/echasnovski/mini.nvim?tab=readme-ov-file#modules
3126
'';
3227
example = {
3328
ai = {
3429
n_lines = 50;
3530
search_method = "cover_or_next";
3631
};
37-
surround = { };
32+
diff = {
33+
view = {
34+
style = "sign";
35+
};
36+
};
37+
comment = {
38+
mappings = {
39+
comment = "<leader>/";
40+
comment_line = "<leader>/";
41+
comment_visual = "<leader>/";
42+
textobject = "<leader>/";
43+
};
44+
};
45+
surround = {
46+
mappings = {
47+
add = "gsa";
48+
delete = "gsd";
49+
find = "gsf";
50+
find_left = "gsF";
51+
highlight = "gsh";
52+
replace = "gsr";
53+
update_n_lines = "gsn";
54+
};
55+
};
56+
starter = {
57+
header = ''
58+
███╗ ██╗██╗██╗ ██╗██╗ ██╗██╗███╗ ███╗
59+
████╗ ██║██║╚██╗██╔╝██║ ██║██║████╗ ████║
60+
██╔██╗ ██║██║ ╚███╔╝ ██║ ██║██║██╔████╔██║
61+
██║╚██╗██║██║ ██╔██╗ ╚██╗ ██╔╝██║██║╚██╔╝██║
62+
██║ ╚████║██║██╔╝ ██╗ ╚████╔╝ ██║██║ ╚═╝ ██║
63+
'';
64+
evaluate_single = true;
65+
items = {
66+
"__unkeyed-1.buildtin_actions".__raw = "require('mini.starter').sections.builtin_actions()";
67+
"__unkeyed-2.recent_files_current_directory".__raw = "require('mini.starter').sections.recent_files(10, false)";
68+
"__unkeyed-3.recent_files".__raw = "require('mini.starter').sections.recent_files(10, true)";
69+
"__unkeyed-4.sessions".__raw = "require('mini.starter').sections.sessions(5, true)";
70+
};
71+
content_hooks = {
72+
"__unkeyed-1.adding_bullet".__raw = "require('mini.starter').gen_hook.adding_bullet()";
73+
"__unkeyed-2.indexing".__raw = "require('mini.starter').gen_hook.indexing('all', { 'Builtin actions' })";
74+
"__unkeyed-3.padding".__raw = "require('mini.starter').gen_hook.aligning('center', 'center')";
75+
};
76+
};
3877
};
3978
};
4079
};
4180

42-
config = mkIf cfg.enable {
43-
extraPlugins = [ cfg.package ];
44-
45-
extraConfigLua = concatLines (
46-
mapAttrsToList (
47-
name: config: "require('mini.${name}').setup(${helpers.toLuaObject config})"
48-
) cfg.modules
49-
);
81+
# NOTE: We handle each module explicitly and not a parent settings table
82+
callSetup = false;
83+
hasSettings = false;
84+
extraConfig = cfg: {
85+
extraConfigLua = lib.foldlAttrs (lines: name: config: ''
86+
${lines}
87+
require(${lib.nixvim.toLuaObject "mini.${name}"}).setup(${lib.nixvim.toLuaObject config})
88+
'') "" cfg.modules;
5089
};
5190
}

0 commit comments

Comments
 (0)