diff --git a/modules/default.nix b/modules/default.nix index fa72b9b..737fe5c 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -92,8 +92,10 @@ inputs: { extraLuaPackages = ps: map (x: ps.${x}) vimOptions.luaPackages; extraPython3Packages = ps: map (x: ps.${x}) vimOptions.python3Packages; - extraWrapperArgs = - concatStringsSep " " (optional (vimOptions.extraPackages != []) ''--prefix PATH : "${makeBinPath vimOptions.extraPackages}"''); + extraWrapperArgs = concatStringsSep " " (optional (vimOptions.extraPackages != []) '' + --unset XDG_DATA_DIRS \ + --prefix PATH : "${makeBinPath vimOptions.extraPackages}" + ''); # wrap user's desired neovim package with the desired neovim configuration # using wrapNeovimUnstable and makeNeovimConfig from nixpkgs. @@ -119,6 +121,8 @@ in { inherit (module) options config; inherit (module._module.args) pkgs; - # expose wrapped neovim-package - neovim = neovim-wrapped; + # expose wrapped neovim package + neovim = neovim-wrapped.overrideAttrs (old: { + generatedWrapperArgs = (old.generatedWrapperArgs or []) ++ ["--set" "NVIM_APPNAME" "nvf"]; + }); } diff --git a/modules/wrapper/rc/options.nix b/modules/wrapper/rc/options.nix index 21da8b2..ccbadcb 100644 --- a/modules/wrapper/rc/options.nix +++ b/modules/wrapper/rc/options.nix @@ -60,6 +60,13 @@ in { path = ./runtime; name = "nvim-runtime"; }) + + # as a Neovim plugin - pure, reproducible and follows Neovim practices + (pkgs.vimUtils.buildVimPlugin { + pname = "nvim-runtime"; + src = ./nvim-runtime; # needs a plugin/init.lua, can refer to modules in a root level lua/ dir + version = "#"; + }) ] ''; @@ -133,14 +140,27 @@ in { -- Remove default user runtime paths from the -- `runtimepath` option to avoid leaking user configuration -- into the final neovim wrapper - 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 - } + local defaultRuntimePaths = {} + local function addPath(path) + table.insert(defaultRuntimePaths, path) + table.insert(defaultRuntimePaths, path .. "/site") + end + + -- Add standard paths to the table + addPath(vim.fn.stdpath('config')) -- $HOME/.config/nvim + addPath(vim.fn.stdpath('data')) -- $HOME/.local/share + addPath(vim.fn.stdpath('state')) -- $HOME/.local/state + addPath(vim.fn.stdpath('cache')) -- $HOME/.cache/nvim + addPath(vim.fn.stdpath('config_dirs')) + addPath(vim.fn.stdpath('data_dirs')) for _, path in ipairs(defaultRuntimePaths) do - vim.opt.runtimepath:remove(path) + -- Check if the path exists in runtimepath before removing it + if vim.fn.index(vim.opt.runtimepath, path) >= 0 then + vim.opt.runtimepath:remove(path) + else + print("Path does not exist in runtimepath:", path) + end end ''}