From 4b868d0de680b378b3f5e24515ceec8b314d0990 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 23 Apr 2024 21:10:39 +0300 Subject: [PATCH] wrapper/rc: loop over removed runtime paths Would be neat to expose removed paths as a list in the future --- modules/wrapper/rc/options.nix | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/modules/wrapper/rc/options.nix b/modules/wrapper/rc/options.nix index 44199ec..21da8b2 100644 --- a/modules/wrapper/rc/options.nix +++ b/modules/wrapper/rc/options.nix @@ -49,8 +49,17 @@ in { default = []; example = literalExpression '' [ - "$HOME/.config/nvim-extra" # absolute path, as a string - impure - ./nvim # relative path, as a path - pure + # absolute path, as a string - impure + "$HOME/.config/nvim-extra" + + # relative path, as a path - pure + ./nvim + + # source type path - pure and reproducible + (builtins.source { + path = ./runtime; + name = "nvim-runtime"; + }) ] ''; @@ -124,9 +133,15 @@ in { -- 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 + local defaultRuntimePaths = { + vim.fn.stdpath('config'), -- $HOME/.config/nvim + vim.fn.stdpath('config') .. "/after", -- $HOME/.config/nvim/after + vim.fn.stdpath('data') .. "/site", -- $HOME/.local/share/nvim/site + } + + for _, path in ipairs(defaultRuntimePaths) do + vim.opt.runtimepath:remove(path) + end ''} ${optionalString cfg.enableLuaLoader "vim.loader.enable()"} @@ -134,9 +149,9 @@ in { defaultText = literalMD '' By default, this option will **append** paths in - [vim.additionalRuntimePaths](#opt-vim.additionalRuntimePaths) + [](#opt-vim.additionalRuntimePaths) to the `runtimepath` and enable the experimental Lua module loader - if [vim.enableLuaLoader](#opt-vim.enableLuaLoader) is set to true. + if [](#opt-vim.enableLuaLoader) is set to true. ''; example = literalExpression ''"$${builtins.readFile ./my-lua-config-pre.lua}"'';