neovim: move plugins where expected

so we dont have to add some nix store path to rtp in the wrapper.
Makes the setup more in line with what neovim users are used to.
Also it means other neovim GUIs can see the plugins without wrapping.

A first version of this PR conflicted with existing
~/.local/share/nvim/site folders but this should be fine as it makes
only a subfolder readonly. 
I am able to mix rocks.nvim/vim.pack vim packages along with the
home-manager one for instance.
This commit is contained in:
teto 2026-01-17 00:54:18 +01:00 committed by Matthieu Coudron
parent 2954aa2944
commit 8968092456
2 changed files with 20 additions and 15 deletions

View file

@ -0,0 +1,8 @@
{ config, ... }:
{
time = "2026-01-19T01:17:02+00:00";
condition = config.programs.neovim.enable;
message = ''
The neovim module now symlinks its plugins into xdg.dataFile."nvim/site/pack/hm" ( ~/.local/share/nvim) instead of modifying the runtimepath via wrapper arguments.
'';
}

View file

@ -437,16 +437,6 @@ in
vimPackageInfo = neovimUtils.makeVimPackageInfo (map suppressNotVimlConfig pluginsNormalized);
packpathDirs.hm = vimPackageInfo.vimPackage;
finalPackdir = neovimUtils.packDir packpathDirs;
packpathWrapperArgs = lib.optionals (packpathDirs.hm.start != [ ] || packpathDirs.hm.opt != [ ]) [
"--add-flags"
''--cmd "set packpath^=${finalPackdir}"''
"--add-flags"
''--cmd "set rtp^=${finalPackdir}"''
];
wrappedNeovim' = pkgs.wrapNeovimUnstable cfg.package {
withNodeJs = cfg.withNodeJs || cfg.coc.enable;
plugins = [ ];
@ -466,11 +456,7 @@ in
ps: (cfg.extraPython3Packages ps) ++ (lib.concatMap (f: f ps) vimPackageInfo.pluginPython3Packages);
neovimRcContent = cfg.extraConfig;
wrapperArgs =
cfg.extraWrapperArgs
++ extraMakeWrapperArgs
++ extraMakeWrapperLuaCArgs
++ extraMakeWrapperLuaArgs
++ packpathWrapperArgs;
cfg.extraWrapperArgs ++ extraMakeWrapperArgs ++ extraMakeWrapperLuaCArgs ++ extraMakeWrapperLuaArgs;
wrapRc = false;
};
in
@ -531,6 +517,17 @@ in
))
];
# link the packpath in expected folder so that even unwrapped neovim can pick
# home-manager's plugins
xdg.dataFile."nvim/site/pack/hm" =
let
packpathDirs.hm = vimPackageInfo.vimPackage;
in
{
enable = allPlugins != [ ];
source = "${pkgs.neovimUtils.packDir packpathDirs}/pack/hm";
};
xdg.configFile = lib.mkMerge (
# writes runtime
(map (x: x.runtime) pluginsNormalized)