neovim: rework provider working

Part of the work to limit the need for wrapping neovim and all its
associated problems.
I dont know why those providers "neovim-node-host" etc were added to the wrapper bin/ directory.
It's probably easier when testing the providers but neovim plugins
should refer to "vim.g.${prog}_host_prog" anyway.
This commit is contained in:
teto
2026-03-01 21:35:49 +01:00
parent 6d3b61b190
commit bf8d7f1803
2 changed files with 29 additions and 21 deletions
+1 -1
View File
@@ -216,7 +216,7 @@
- `mold` is now wrapped by default.
- `neovim` now disables by default the `python3` and `ruby` providers, unused by most users and reducing closure size from 365MiB to 240MiB.
- `neovim` now disables by default the `python3` and `ruby` providers, unused by most users and reducing closure size from 365MiB to 240MiB. Host provider executables are not exposed anymore along with the neovim wrapper. You can still refer to those using the neovim provider variables (e.g., `python3_host_prog`).
### Deprecations {#sec-nixpkgs-release-26.05-lib-deprecations}
+28 -20
View File
@@ -15,6 +15,7 @@
perl,
lndir,
vimUtils,
runCommand,
}:
neovim-unwrapped:
@@ -154,14 +155,33 @@ let
(lib.makeBinPath finalAttrs.runtimeDeps)
];
providerLuaRc = neovimUtils.generateProviderRc {
inherit (finalAttrs)
withPython3
withNodeJs
withPerl
withRuby
;
};
providerLuaRc =
let
hostPython3 =
runCommand "nvim-host-${python3Env.name}"
{
nativeBuildInputs = [
makeWrapper
];
}
''
makeWrapper ${python3Env.interpreter} $out/bin/nvim-python3 --unset PYTHONPATH --unset PYTHONSAFEPATH
'';
genProviderCommand =
prog: withProg: exec:
if withProg then
"vim.g.${prog}_host_prog='${exec}'"
else
# speeds up neovim by bypassing provider discovery
"vim.g.loaded_${prog}_provider=0";
in
lib.concatStringsSep ";" [
(genProviderCommand "node" finalAttrs.withNodeJs "${neovim-node-client}/bin/neovim-node-host")
(genProviderCommand "perl" finalAttrs.withPerl "${perlEnv}/bin/perl")
(genProviderCommand "ruby" finalAttrs.withRuby "${finalAttrs.rubyEnv}/bin/neovim-ruby-host")
(genProviderCommand "python3" finalAttrs.withPython3 "${hostPython3}/bin/nvim-python3")
];
# If `configure` != {}, we can't generate the rplugin.vim file with e.g
# NVIM_SYSTEM_RPLUGIN_MANIFEST *and* NVIM_RPLUGIN_MANIFEST env vars set in
@@ -236,18 +256,6 @@ let
substitute ${neovim-unwrapped}/share/applications/nvim.desktop $out/share/applications/nvim.desktop \
--replace-warn 'Name=Neovim' 'Name=Neovim wrapper'
''
+ lib.optionalString finalAttrs.withPython3 ''
makeWrapper ${python3Env.interpreter} $out/bin/nvim-python3 --unset PYTHONPATH --unset PYTHONSAFEPATH
''
+ lib.optionalString (finalAttrs.withRuby) ''
ln -s ${finalAttrs.rubyEnv}/bin/neovim-ruby-host $out/bin/nvim-ruby
''
+ lib.optionalString finalAttrs.withNodeJs ''
ln -s ${neovim-node-client}/bin/neovim-node-host $out/bin/nvim-node
''
+ lib.optionalString finalAttrs.withPerl ''
ln -s ${perlEnv}/bin/perl $out/bin/nvim-perl
''
+ lib.optionalString finalAttrs.vimAlias ''
ln -s $out/bin/nvim $out/bin/vim
''