modules/lua-loader: add support for the new lua-loader (#336)

This commit is contained in:
Gaétan Lepage 2023-04-15 16:32:10 +02:00 committed by GitHub
parent 8ba084783e
commit a9e3ff3f73
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 44 additions and 0 deletions

35
modules/lua-loader.nix Normal file
View file

@ -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()";
};
}