modules/output: add impureRtp option

Instead of assuming `wrapRc` implies we don't want impurities, configure
this separately.
This commit is contained in:
Matt Sturgeon 2024-09-25 17:43:04 +01:00
parent fb7cda2868
commit 11924e1593
No known key found for this signature in database
GPG key ID: 4F91844CED1A8299
2 changed files with 16 additions and 2 deletions

View file

@ -56,6 +56,18 @@ in
'';
};
impureRtp = mkOption {
type = types.bool;
description = ''
Whether to keep the (impure) nvim config directory in the runtimepath.
If disabled, the XDG config dirs `nvim` and `nvim/after` will be removed from the runtimepath.
'';
defaultText = lib.literalMD ''
Configured by your installation method: `true` when using the home-manager module, `false` otherwise.
'';
};
finalPackage = mkOption {
type = types.package;
description = "Wrapped Neovim.";
@ -290,12 +302,13 @@ in
'';
};
# Set `wrapRc`s option default with even lower priority than `mkOptionDefault`
# Set `wrapRc` and `impureRtp`s option defaults with even lower priority than `mkOptionDefault`
wrapRc = lib.mkOverride 1501 true;
impureRtp = lib.mkOverride 1501 false;
extraConfigLuaPre = lib.mkOrder 100 (
lib.concatStringsSep "\n" (
lib.optional config.wrapRc ''
lib.optional (!config.impureRtp) ''
-- Ignore the user lua configuration
vim.opt.runtimepath:remove(vim.fn.stdpath('config')) -- ~/.config/nvim
vim.opt.runtimepath:remove(vim.fn.stdpath('config') .. "/after") -- ~/.config/nvim/after

View file

@ -27,6 +27,7 @@ let
_file = ./hm.nix;
config = {
wrapRc = lib.mkOptionDefault false;
impureRtp = lib.mkOptionDefault true;
};
}
];