diff --git a/modules/lua-loader.nix b/modules/lua-loader.nix new file mode 100644 index 00000000..26054d5b --- /dev/null +++ b/modules/lua-loader.nix @@ -0,0 +1,35 @@ +{ + config, + lib, + ... +}: +with lib; let + cfg = config.luaLoader; +in { + options.luaLoader = { + enable = mkOption { + type = types.bool; + default = false; + description = '' + Whether to enable/disable the experimental lua loader: + + If `true`: Enables the experimental Lua module loader: + - overrides loadfile + - adds the lua loader using the byte-compilation cache + - adds the libs loader + - removes the default Neovim loade + + If `false`: Disables the experimental Lua module loader: + - removes the loaders + - adds the default Neovim loader + ''; + }; + }; + + config = { + extraConfigLuaPre = + if cfg.enable + then "vim.loader.enable()" + else "vim.loader.disable()"; + }; +} diff --git a/tests/test-sources/modules/lua-loader.nix b/tests/test-sources/modules/lua-loader.nix new file mode 100644 index 00000000..24ab102b --- /dev/null +++ b/tests/test-sources/modules/lua-loader.nix @@ -0,0 +1,9 @@ +{ + enabled = { + luaLoader.enable = true; + }; + + disabled = { + luaLoader.enable = false; + }; +}