|
| 1 | +{ |
| 2 | + lazy-load-neovim-plugin-configured = |
| 3 | + { config, lib, ... }: |
| 4 | + { |
| 5 | + plugins = { |
| 6 | + lazy = { |
| 7 | + enable = true; |
| 8 | + }; |
| 9 | + |
| 10 | + neotest = { |
| 11 | + enable = true; |
| 12 | + lazyLoad = { |
| 13 | + enable = true; |
| 14 | + settings = { |
| 15 | + cmd = [ "Neotest" ]; |
| 16 | + }; |
| 17 | + }; |
| 18 | + }; |
| 19 | + }; |
| 20 | + |
| 21 | + assertions = [ |
| 22 | + { |
| 23 | + assertion = (builtins.length config.plugins.lazy.plugins) == 1; |
| 24 | + message = "`lazy.plugins` should have contained a single plugin configuration, but contained ${builtins.toJSON config.plugins.lz-n.plugins}"; |
| 25 | + } |
| 26 | + { |
| 27 | + assertion = |
| 28 | + let |
| 29 | + plugins = config.plugins.lazy.plugins or [ ]; |
| 30 | + plugin = if builtins.length plugins > 0 then builtins.head plugins else null; |
| 31 | + cmd = if plugin != null && builtins.isList plugin.cmd then plugin.cmd else [ ]; |
| 32 | + in |
| 33 | + (builtins.length cmd) == 1; |
| 34 | + message = "`lazy.plugins[0].cmd` should have contained a configuration."; |
| 35 | + } |
| 36 | + { |
| 37 | + assertion = |
| 38 | + let |
| 39 | + plugins = config.plugins.lazy.plugins or [ ]; |
| 40 | + plugin = if builtins.length plugins > 0 then builtins.head plugins else null; |
| 41 | + in |
| 42 | + plugin != null && lib.hasInfix config.plugins.neotest.luaConfig.content plugin.config.__raw; |
| 43 | + message = "`lazy.plugins[0].after` should have contained `neotest` lua content."; |
| 44 | + } |
| 45 | + ]; |
| 46 | + }; |
| 47 | + |
| 48 | + dont-lazy-load-unconfigured = |
| 49 | + { config, ... }: |
| 50 | + { |
| 51 | + plugins = { |
| 52 | + neotest = { |
| 53 | + enable = true; |
| 54 | + # Empty attrset shouldn't trigger lazy loading |
| 55 | + lazyLoad = { }; |
| 56 | + }; |
| 57 | + lazy = { |
| 58 | + enable = true; |
| 59 | + }; |
| 60 | + }; |
| 61 | + |
| 62 | + assertions = [ |
| 63 | + { |
| 64 | + assertion = (builtins.length config.plugins.lazy.plugins) == 0; |
| 65 | + message = "`lazy.plugins` should have contained no plugin configuration, but contained ${builtins.toJSON config.plugins.lz-n.plugins}"; |
| 66 | + } |
| 67 | + ]; |
| 68 | + }; |
| 69 | + |
| 70 | + lazy-load-enabled-automatically = |
| 71 | + { config, ... }: |
| 72 | + { |
| 73 | + plugins = { |
| 74 | + lazy = { |
| 75 | + enable = true; |
| 76 | + }; |
| 77 | + neotest = { |
| 78 | + enable = true; |
| 79 | + lazyLoad = { |
| 80 | + # Not setting lazyLoad.enable with configuration should enable |
| 81 | + settings = { |
| 82 | + cmd = [ "Neotest" ]; |
| 83 | + }; |
| 84 | + }; |
| 85 | + }; |
| 86 | + }; |
| 87 | + |
| 88 | + assertions = [ |
| 89 | + { |
| 90 | + assertion = (builtins.length config.plugins.lazy.plugins) == 1; |
| 91 | + message = "`lazy.plugins` should have contained a single plugin configuration, but contained ${builtins.toJSON config.plugins.lz-n.plugins}"; |
| 92 | + } |
| 93 | + { |
| 94 | + assertion = |
| 95 | + let |
| 96 | + plugins = config.plugins.lazy.plugins or [ ]; |
| 97 | + plugin = if builtins.length plugins > 0 then builtins.head plugins else null; |
| 98 | + cmd = if plugin != null && builtins.isList plugin.cmd then plugin.cmd else [ ]; |
| 99 | + in |
| 100 | + (builtins.length cmd) == 1; |
| 101 | + message = "`lazy.plugins[0].cmd` should have contained a configuration."; |
| 102 | + } |
| 103 | + ]; |
| 104 | + }; |
| 105 | + wrap-functionless-luaConfig = |
| 106 | + { config, ... }: |
| 107 | + { |
| 108 | + plugins = { |
| 109 | + lazy = { |
| 110 | + enable = true; |
| 111 | + }; |
| 112 | + web-devicons.enable = false; |
| 113 | + telescope = { |
| 114 | + enable = true; |
| 115 | + lazyLoad = { |
| 116 | + enable = true; |
| 117 | + settings = { |
| 118 | + cmd = [ "Telescope" ]; |
| 119 | + }; |
| 120 | + }; |
| 121 | + }; |
| 122 | + }; |
| 123 | + |
| 124 | + assertions = [ |
| 125 | + { |
| 126 | + assertion = (builtins.length config.plugins.lazy.plugins) == 1; |
| 127 | + message = "`lazy.plugins` should have contained a single plugin configuration, but contained ${builtins.toJSON config.plugins.lz-n.plugins}"; |
| 128 | + } |
| 129 | + { |
| 130 | + assertion = |
| 131 | + let |
| 132 | + plugin = builtins.head config.plugins.lazy.plugins; |
| 133 | + in |
| 134 | + plugin.config.__raw == "function()\n " + config.plugins.telescope.luaConfig.content + " \nend"; |
| 135 | + message = "`lazy.plugins[0].config` should have contained a function wrapped `telescope` lua content."; |
| 136 | + } |
| 137 | + ]; |
| 138 | + }; |
| 139 | +} |
0 commit comments