From fecf9f48bebf86953c33210e9f73fe1d95c1b8e4 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sun, 21 Apr 2024 02:59:18 +0300 Subject: [PATCH] wrapper/rc: ignore user directories by default --- modules/wrapper/rc/options.nix | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/modules/wrapper/rc/options.nix b/modules/wrapper/rc/options.nix index c67cf1e..3d0c9a3 100644 --- a/modules/wrapper/rc/options.nix +++ b/modules/wrapper/rc/options.nix @@ -24,6 +24,26 @@ in { take a look at the [{option}`official documentation`](https://neovim.io/doc/user/lua.html#vim.loader.enable()). ''; + disableDefaultRuntimePaths = mkOption { + type = bool; + default = true; + example = false; + description = '' + Disables the default runtime paths that are set by Neovim + when it starts up. This is useful when you want to have + full control over the runtime paths that are set by Neovim. + + ::: {.note} + To avoid leaking imperative user configuration into your + configuration, this is enabled by default. If you wish + to load configuration from user configuration directories + (e.g. `$HOME/.config/nvim`, `$HOME/.config/nvim/after` + and `$HOME/.local/share/nvim/site`) you may set this + option to true. + ::: + ''; + }; + additionalRuntimePaths = mkOption { type = listOf (either path str); default = []; @@ -90,6 +110,15 @@ in { end ''} + ${optionalString cfg.disableDefaultRuntimePaths '' + -- Remove default user runtime paths from the + -- `runtimepath` option to avoid leaking user configuration + -- into the final neovim wrapper + vim.opt.runtimepath:remove(vim.fn.stdpath('config')) -- $HOME/.config/nvim + vim.opt.runtimepath:remove(vim.fn.stdpath('config') .. "/after") -- $HOME/.config/nvim/after + vim.opt.runtimepath:remove(vim.fn.stdpath('data') .. "/site") -- $HOME/.local/share/nvim/site + ''} + ${optionalString cfg.enableLuaLoader "vim.loader.enable()"} '';