diff --git a/plugins/by-name/lzn-auto-require/default.nix b/plugins/by-name/lzn-auto-require/default.nix new file mode 100644 index 00000000..947b0056 --- /dev/null +++ b/plugins/by-name/lzn-auto-require/default.nix @@ -0,0 +1,16 @@ +{ lib, ... }: +lib.nixvim.plugins.mkNeovimPlugin { + name = "lzn-auto-require"; + description = '' + Auto load optional plugins via lua modules with `lz.n`. + + This plugin overrides the `require` function to also search for plugins in + `{packpath}/*/opt` and load them using `lz.n`. + ''; + + hasSettings = false; + setup = ".enable"; + configLocation = lib.mkOrder 5000 "extraConfigLuaPost"; # Register after everything to catch mistates + + maintainers = [ lib.maintainers.axka ]; +} diff --git a/tests/test-sources/plugins/by-name/lzn-auto-require/default.nix b/tests/test-sources/plugins/by-name/lzn-auto-require/default.nix new file mode 100644 index 00000000..d0cfe598 --- /dev/null +++ b/tests/test-sources/plugins/by-name/lzn-auto-require/default.nix @@ -0,0 +1,28 @@ +{ + e2e = + { lib, ... }: + { + plugins.lz-n.enable = true; + plugins.lzn-auto-require.enable = true; + + plugins.smart-splits = { + enable = true; + lazyLoad.settings.lazy = true; # manual lazy-loading + }; + + extraConfigLuaPost = lib.mkMerge [ + (lib.mkOrder 4999 '' + local success, _ = pcall(require, 'smart-splits') + if success then + print("require should not succeed") + end + '') + (lib.mkOrder 5001 '' + local success, _ = pcall(require, 'smart-splits') + if not success then + print("require should succeed") + end + '') + ]; + }; +}