|
1 | 1 | { |
2 | 2 | lib, |
3 | | - helpers, |
4 | | - config, |
5 | | - pkgs, |
6 | 3 | ... |
7 | 4 | }: |
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"; |
15 | 8 |
|
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"; |
22 | 12 |
|
23 | | - modules = mkOption { |
24 | | - type = with types; attrsOf attrs; |
| 13 | + extraOptions = { |
| 14 | + modules = lib.mkOption { |
| 15 | + type = with lib.types; attrsOf (attrsOf anything); |
25 | 16 | default = { }; |
26 | 17 | description = '' |
27 | 18 | 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 |
31 | 26 | ''; |
32 | 27 | example = { |
33 | 28 | ai = { |
34 | 29 | n_lines = 50; |
35 | 30 | search_method = "cover_or_next"; |
36 | 31 | }; |
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 | + }; |
38 | 77 | }; |
39 | 78 | }; |
40 | 79 | }; |
41 | 80 |
|
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; |
50 | 89 | }; |
51 | 90 | } |
0 commit comments