From bf8d7f18033f9ce3dcfff8e700eedd8fd9272c0c Mon Sep 17 00:00:00 2001 From: teto <886074+teto@users.noreply.github.com> Date: Sat, 28 Feb 2026 16:49:41 +0100 Subject: [PATCH] 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. --- doc/release-notes/rl-2605.section.md | 2 +- pkgs/applications/editors/neovim/wrapper.nix | 48 ++++++++++++-------- 2 files changed, 29 insertions(+), 21 deletions(-) diff --git a/doc/release-notes/rl-2605.section.md b/doc/release-notes/rl-2605.section.md index 59adc9673baf..dcaa1531d175 100644 --- a/doc/release-notes/rl-2605.section.md +++ b/doc/release-notes/rl-2605.section.md @@ -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} diff --git a/pkgs/applications/editors/neovim/wrapper.nix b/pkgs/applications/editors/neovim/wrapper.nix index 5234ad484c41..5fba635a2c48 100644 --- a/pkgs/applications/editors/neovim/wrapper.nix +++ b/pkgs/applications/editors/neovim/wrapper.nix @@ -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 ''