diff --git a/lib/neovim-plugin.nix b/lib/neovim-plugin.nix index bbb5324b37..9b97ab8b7b 100644 --- a/lib/neovim-plugin.nix +++ b/lib/neovim-plugin.nix @@ -113,6 +113,30 @@ ''; internal = true; }; + + lazyLoad = lib.mkOption { + default = { + enable = false; + }; + description = '' + Lazy load configuration settings. + ''; + type = lib.types.submodule { + options = { + enable = lib.mkOption { + default = false; + type = lib.types.bool; + description = '' + Whether to lazy load the plugin. + + If you enable this, the plugin's lua configuration will need to be manually loaded by other means. + + A usage would be passing the plugin's luaConfig to the `plugins.lz-n.plugins` configuration. + ''; + }; + }; + }; + }; } // lib.optionalAttrs hasSettings { settings = lib.nixvim.mkSettingsOption { @@ -157,7 +181,9 @@ ]) ++ (lib.optionals hasConfigAttrs [ (lib.optionalAttrs callSetup { ${namespace}.${name}.luaConfig.content = setupCode; }) - (lib.optionalAttrs (configLocation != null) (setLuaConfig cfg.luaConfig.content)) + (lib.mkIf (!cfg.lazyLoad.enable) ( + lib.optionalAttrs (configLocation != null) (setLuaConfig cfg.luaConfig.content) + )) ]) ) ); diff --git a/tests/test-sources/plugins/lazy-load.nix b/tests/test-sources/plugins/lazy-load.nix new file mode 100644 index 0000000000..24dc614071 --- /dev/null +++ b/tests/test-sources/plugins/lazy-load.nix @@ -0,0 +1,34 @@ +{ + lazy-load-plugin = + { config, ... }: + { + plugins = { + lz-n = { + enable = true; + plugins = [ + { + __unkeyed-1 = "neotest"; + after.__raw = '' + function() + ${config.plugins.neotest.luaConfig.content} + end + ''; + keys = [ + { + __unkeyed-1 = "nt"; + __unkeyed-3 = "Neotest summary"; + desc = "Summary toggle"; + } + ]; + + } + ]; + }; + + neotest = { + enable = true; + lazyLoad.enable = true; + }; + }; + }; +}