Skip to content

neovim: set provider configuration to initrc#487390

Merged
teto merged 2 commits into
NixOS:masterfrom
teto:teto/neovim-set-provider-in-init
Feb 15, 2026
Merged

neovim: set provider configuration to initrc#487390
teto merged 2 commits into
NixOS:masterfrom
teto:teto/neovim-set-provider-in-init

Conversation

@teto

@teto teto commented Feb 5, 2026

Copy link
Copy Markdown
Member

Things done

as an attempt to simplify configuration. Third parties can just refer to the generated init.lua instead of having to refer to it + regenerate the wrapper arguments (ruby still needs special treatement via GEM_HOME set apparently).

I wonder if this needs release notes, I dont know if nixvim / kickcats depend on the nixpkgs wrapper or if it just rewrites the whole logic.

  • Built on platform:
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • Tested, as applicable:
  • Ran nixpkgs-review on this PR. See nixpkgs-review usage.
  • Tested basic functionality of all binary files, usually in ./result/bin/.
  • Nixpkgs Release Notes
    • Package update: when the change is major or breaking.
  • NixOS Release Notes
    • Module addition: when adding a new NixOS module.
    • Module update: when the change is significant.
  • Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md and other READMEs.

@nixpkgs-ci nixpkgs-ci Bot added 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 6.topic: vim Advanced text editor labels Feb 5, 2026
@teto

teto commented Feb 9, 2026

Copy link
Copy Markdown
Member Author

for context, I would like to make it possible for home-manager to just skip wrapping neovim-unwrapped entirely in most cases. Also I noticed we have withRuby ? true in wrapNeovimUnstable which I find odd especially as the legacy wrapper defaults it to false. I might disable it in a separate PR.

@nixpkgs-ci nixpkgs-ci Bot requested a review from a team February 10, 2026 20:57
Comment on lines -128 to -132
generatedWrapperArgs = [
# vim accepts a limited number of commands so we join all the provider ones
"--add-flags"
''--cmd "lua ${providerLuaRc}"''
]

@khaneliman khaneliman Feb 10, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would be the result of losing these providerLuaRc variables for a downstream consumer of the wrapper?

Before:

exec "/nix/store/wr7j2629j0hmipa1mb966xagk174q5ky-neovim-byte-compiled-0.11.6/bin/nvim"  --cmd "lua
vim.g.loaded_node_provider=0;vim.g.loaded_perl_provider=0;vim.g.loaded_python_provider=0;vim.g.python3_host_prog='/nix/store/c4bfr9cl8nmlggzjg40q3z5pvalpgpkz-neovim-0.11.6/bin/nvim-python3';vim.g.ruby_host_prog='/nix/store/c4bfr9cl8nmlggzjg40q3z5pvalpgpkz-neovim-0.11.6/bin/nvim-ruby'" --cmd "set packpath^=/nix/store/q8cjdv0idypwjypmai84mg4g1pymws3a-vim-pack-dir" --cmd "set rtp^=/nix/store/q8cjdv0idypwjypmai84mg4g1pymws3a-vim-pack-dir" -u
/nix/store/g8d7m5y1alrh0w71phig6kyah9q2b66v-init.lua "$@"

After:

exec "/nix/store/wr7j2629j0hmipa1mb966xagk174q5ky-neovim-byte-compiled-0.11.6/bin/nvim"  --cmd "set packpath^=/nix/store/xssf72bmwy0pqhb8sk4rz3djs4nww7rp-vim-pack-dir" --cmd "set
rtp^=/nix/store/xssf72bmwy0pqhb8sk4rz3djs4nww7rp-vim-pack-dir" -u /nix/store/86sl0w2kp7f6hm6vqhhpqb75gvy5lfhn-init.lua "$@"

Is this just going to make Neovim search for those on PATH instead of automatically including the direct paths?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i.e a plain user should not see the difference, someone setting wrapRc = false will be fine if he already includes the wrapper luaRcContent somehow. If he doesn't, now he must :p

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess what I was trying to figure out was, this is technically a breaking change that generates a different wrapper for those relying on it from there. What is the effect of that no longer being included in the wrapper and / or recommended migration for consumers of the existing wrapper semantics?

Should probably have a short blurb in release notes about the behavior changing so there's something to reference if a config stops working how it had before the change.

Just trying to avoid surprising people with undocumented changes if they will affect neovim at runtime.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe i'm being overly cautious @mrcjkb any thoughts?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before this PR, the neovim wrapper was invoked with

nvim --cmd ":lua ${providerLuaRc}" "$@"

--cmd flags are invoked after init.lua (you can test this by adding vim.g.foo = "hello" to your init.lua and then running nvim --cmd ":lua vim.print(vim.g.foo or 'foo unset')").

So this PR moves the sourcing of the providerLuaRc to an earlier point of Neovim's startup sequence.

Technically, a config could break if it tries to use one of the providers in the init.lua and the user doesn't know that they have it disabled.
I think it's highly unlikely, as providers are typically used by plugins and Neovim loads providers lazily using :h autoload scripts.
For example, the python provider is only loaded if a user or a plugin calls the Vimscript function provider#python3#Call or provider#python3#Require.

@teto teto Feb 12, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If anything setting the providers earlier could fix things where a plugin checks if the provider is set (and currently thinks it's not). I doubt many users use remote plugins. With the remark of marc, I've updated the commit description to :

  1. mention who might be concerned ( which I think is really a small number)
  2. how to fix that in those degenerate cases

@teto teto force-pushed the teto/neovim-set-provider-in-init branch 2 times, most recently from 36cd4d9 to ee3a3d3 Compare February 12, 2026 02:32
@nixpkgs-ci nixpkgs-ci Bot added the 12.approvals: 1 This PR was reviewed and approved by one person. label Feb 12, 2026
@teto teto force-pushed the teto/neovim-set-provider-in-init branch 2 times, most recently from 16ae792 to b2c0d1a Compare February 12, 2026 12:35
teto added a commit to teto/home-manager that referenced this pull request Feb 12, 2026
now that home-manager always generates an init.lua we can take the
wrapper output instead of reimplemnting stuff in HM (notwithstanding rtp
changes that are not needed in HM).
This is necessary to keep the provider configuration available after
this change NixOS/nixpkgs#487390
@teto

teto commented Feb 13, 2026

Copy link
Copy Markdown
Member Author

while I think the change is fine for nxipkgs users, it's a bit annoying in home-manager so I will reference it in the nixpkgs changelog. Also I need to complete nix-community/home-manager#8734 before merge

@GaetanLepage

Copy link
Copy Markdown
Contributor

Also I need to complete nix-community/home-manager#8734 before merge

Ok, I will mark this PR as draft in the meantime.

@GaetanLepage GaetanLepage marked this pull request as draft February 14, 2026 21:00
@teto teto force-pushed the teto/neovim-set-provider-in-init branch from b2c0d1a to 362a1fa Compare February 15, 2026 14:36
teto added 2 commits February 15, 2026 15:50
as an attempt to simplify configuration: 
instead of having wrapping arguments + an optional neovim configuration
let's always generate a neovim configuration.
The change should be transparent for most users, and require
intervention for users that fulfill both conditions:
- using remote plugins (rare already)
- that set `wrapRc = false` in wrapNeovimUnstable without loading later
  the generated luaRcContent

The fix is then to pass as wrapping arguments the wrapper's generated config via 

(wrapNeovimUnstable neovim-unwrapped { } ).overrideAttrs(oa: { wrapperArgs = oa.wrapperArgs ++ [ ''--cmd "lua dofile('${writeText "init.lua" oa.luaRcContent}')"'' ]; })

neovim: avoid creating empty newlines
@teto teto force-pushed the teto/neovim-set-provider-in-init branch from 362a1fa to 28b5fc1 Compare February 15, 2026 14:50
@teto

teto commented Feb 15, 2026

Copy link
Copy Markdown
Member Author

Ok, I will mark this PR as draft in the meantime.

ty I should have done so. Putting it out of draft since I've fixed the issues in the HM PR. It took me more time than I wanted but it's an iterative progress as we try not to break configs.
I would like to merge this,

I've suffered from (my) poor naming choice in the wrapper variables, so some notes for possible naming improvements:

  • why do I need precise "neovim" in neovimRcContent' when we are in the neovim wrapper
  • we have luaRcContent = rcContent different from the passed wrapper luaRcContent (which might be voluntary because I wanted users to be able to chain their config via neovim.overrideAttrs(oa: { plugins = .. }).overrideAttrs(oa: { plugins = oa.plugins ++ [ .. ]}).overrideAttrs({ withRuby = false;})such that you dont need to know your full config in advance.
  • in my experience, what I am interested in the exposed variables is: "user" or "generated", "lua" or "viml" so naming should reflect that.

@teto teto marked this pull request as ready for review February 15, 2026 14:51
@nixpkgs-ci nixpkgs-ci Bot added 8.has: changelog This PR adds or changes release notes 8.has: documentation This PR adds or changes documentation labels Feb 15, 2026
@teto teto deleted the teto/neovim-set-provider-in-init branch February 15, 2026 16:40
Lord-Valen pushed a commit to Lord-Valen/nixpkgs that referenced this pull request Feb 15, 2026
teto added a commit to teto/home-manager that referenced this pull request Feb 19, 2026
now that home-manager always generates an init.lua we can take the
wrapper output instead of reimplemnting stuff in HM (notwithstanding rtp
changes that are not needed in HM).
This is necessary to keep the provider configuration available after
this change NixOS/nixpkgs#487390
@stefanboere

Copy link
Copy Markdown

This change breaks my config because the vim.g.python3_host_prog refers to incorrect path.

Contents of the file /nix/store/8y45ym4ab9kbcam4vz4j83xfxkx9jf95-init.lua:

vim.g.node_host_prog='/nix/store/8y45ym4ab9kbcam4vz4j83xfxkx9jf95-init.lua/bin/nvim-node';vim.g.loaded_perl_provider=0;vim.g.loaded_python_provider=0;vim.g.python3_host_prog='/nix/store/8y45ym4ab9kbcam4vz4j83xfxkx9jf95-init.lua/bin/nvim-python3';vim.g.loaded_ruby_provider=0
vim.cmd.source "/nix/store/m3nif8y02vkll3hcml4cz9rnm1zdk98v-init.vim"

But it should refer to the neovim store path itself, not the init.lua store path. So the file nix/store/8y45ym4ab9kbcam4vz4j83xfxkx9jf95-init.lua/bin/nvim-python3 does not exist.

So now in neovim I get the error 'E319: No "python3" provider found.'

@teto

teto commented Feb 19, 2026

Copy link
Copy Markdown
Member Author

ty for warning. If you dont need the python provider, you can disable it via withPython3 = false until it gets fixed. Actually I think we should change all the providers default to false.

@stefanboere

Copy link
Copy Markdown

Yes thank you, I'll just revert to earlier version, no problem. But I send this comment because probably more vim users will get this error, so I was wondering if this could be fixed or otherwise if the commit could be reverted.

And thank you for the effort with this PR and cleaning up the vim configuration :).

@mrcjkb

mrcjkb commented Feb 19, 2026

Copy link
Copy Markdown
Member

The problem seems to be that generateProviderRc uses ${placeholder out}:

"vim.g.${prog}_host_prog='${placeholder "out"}/bin/nvim-${prog}'"

...which now evaluates to init.lua, since providerLuaRc is now part of the initrc.
I think besides reverting this PR, the only fix is to put each provider in its own derivation.

teto added a commit to teto/nixpkgs that referenced this pull request Feb 19, 2026
We used to unconditionnally wrap the provider configuration.
NixOS#487390 tries to "smartly" embed it into
init.lua but that breaks neovim legacy behavior in some cases since `wrapRc` is set to false in absence of user configuration.
One day we will get rid of the legacy wrapper but until then keep that
behavior.
teto added a commit to teto/nixpkgs that referenced this pull request Feb 19, 2026
We used to unconditionnally wrap the provider configuration.
NixOS#487390 "smartly" embeds it into
init.lua depending on `wrapRc` but that breaks neovim legacy behavior in some cases since `legacyWrapper` sets `wrapRc` to false in absence of some of user configuration.
One day we will get rid of the legacy wrapper but until then keep that behavior.

Most of the changes come from linter.
teto added a commit to teto/nixpkgs that referenced this pull request Feb 19, 2026
We used to unconditionnally wrap the provider configuration.
NixOS#487390 "smartly" embeds it into
init.lua depending on `wrapRc` but that breaks neovim legacy behavior in some cases since `legacyWrapper` sets `wrapRc` to false in absence of some of user configuration.
One day we will get rid of the legacy wrapper but until then keep that behavior.

Most of the changes come from linter.
@teto

teto commented Feb 19, 2026

Copy link
Copy Markdown
Member Author

I think besides reverting this PR, the only fix is to put each provider in its own derivation.

I can think of other solutions though, like inlining the code. generateProviderRc is a bad abstraction with the placeholder out a footgun. I wanted to avoid the revert but there are too many things that seem wrong at the moment that I would prefer to address first. So le'ts revert. I seem to remember it was possible to revert from github's UI but I can t find it anymore ?
gotta do it the old way then.

EDIT: found the button

@teto teto mentioned this pull request Mar 11, 2026
16 tasks
teto added a commit to teto/nixpkgs that referenced this pull request Mar 11, 2026
We used to unconditionnally wrap the provider configuration.
NixOS#487390 "smartly" embeds it into
init.lua depending on `wrapRc` but that breaks neovim legacy behavior in some cases since `legacyWrapper` sets `wrapRc` to false in absence of some of user configuration.
One day we will get rid of the legacy wrapper but until then keep that behavior.

Most of the changes come from linter.
@nixos-discourse

Copy link
Copy Markdown

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/neovim-provider-options-not-working/76077/2

teto added a commit to teto/home-manager that referenced this pull request Mar 11, 2026
now that home-manager always generates an init.lua we can take the
wrapper output instead of reimplemnting stuff in HM (notwithstanding rtp
changes that are not needed in HM).
This is necessary to keep the provider configuration available after
this change NixOS/nixpkgs#487390
teto added a commit to teto/nixpkgs that referenced this pull request Mar 12, 2026
We used to unconditionnally wrap the provider configuration.
NixOS#487390 "smartly" embeds it into
init.lua depending on `wrapRc` but that breaks neovim legacy behavior in some cases since `legacyWrapper` sets `wrapRc` to false in absence of some of user configuration.
One day we will get rid of the legacy wrapper but until then keep that behavior.

Most of the changes come from linter.
teto added a commit to teto/home-manager that referenced this pull request Mar 12, 2026
now that home-manager always generates an init.lua we can take the
wrapper output instead of reimplemnting stuff in HM (notwithstanding rtp
changes that are not needed in HM).
This is necessary to keep the provider configuration available after
this change NixOS/nixpkgs#487390
teto added a commit to teto/home-manager that referenced this pull request Mar 12, 2026
now that home-manager always generates an init.lua we can take the
wrapper output instead of reimplemnting stuff in HM (notwithstanding rtp
changes that are not needed in HM).
This is necessary to keep the provider configuration available after
this change NixOS/nixpkgs#487390

Also updated test to reflect ruby disabling
teto added a commit to teto/nixpkgs that referenced this pull request Mar 12, 2026
We used to unconditionnally wrap the provider configuration.
NixOS#487390 "smartly" embeds it into
init.lua depending on `wrapRc` but that breaks neovim legacy behavior in some cases since `legacyWrapper` sets `wrapRc` to false in absence of some of user configuration.
One day we will get rid of the legacy wrapper but until then keep that behavior.

Most of the changes come from linter.
teto added a commit to teto/nixpkgs that referenced this pull request Mar 13, 2026
We used to unconditionnally wrap the provider configuration.
NixOS#487390 "smartly" embeds it into
init.lua depending on `wrapRc` but that breaks neovim legacy behavior in some cases since `legacyWrapper` sets `wrapRc` to false in absence of some of user configuration.
One day we will get rid of the legacy wrapper but until then keep that behavior.

Most of the changes come from linter.
github-actions Bot pushed a commit to Mic92/nixpkgs that referenced this pull request Mar 15, 2026
We used to unconditionnally wrap the provider configuration.
NixOS#487390 "smartly" embeds it into
init.lua depending on `wrapRc` but that breaks neovim legacy behavior in some cases since `legacyWrapper` sets `wrapRc` to false in absence of some of user configuration.
One day we will get rid of the legacy wrapper but until then keep that behavior.

Most of the changes come from linter.
teto added a commit to teto/home-manager that referenced this pull request Mar 17, 2026
now that home-manager always generates an init.lua we can take the
wrapper output instead of reimplemnting stuff in HM (notwithstanding rtp
changes that are not needed in HM).
This is necessary to keep the provider configuration available after
this change NixOS/nixpkgs#487390

Also updated test to reflect ruby disabling
teto added a commit to nix-community/home-manager that referenced this pull request Mar 19, 2026
now that home-manager always generates an init.lua we can take the
wrapper output instead of reimplemnting stuff in HM (notwithstanding rtp
changes that are not needed in HM).
This is necessary to keep the provider configuration available after
this change NixOS/nixpkgs#487390

Also updated test to reflect ruby disabling
teto added a commit to nix-community/home-manager that referenced this pull request Mar 19, 2026
now that home-manager always generates an init.lua we can take the
wrapper output instead of reimplemnting stuff in HM (notwithstanding rtp
changes that are not needed in HM).
This is necessary to keep the provider configuration available after
this change NixOS/nixpkgs#487390

Also updated test to reflect ruby disabling
khaneliman pushed a commit to nix-community/home-manager that referenced this pull request Mar 19, 2026
now that home-manager always generates an init.lua we can take the
wrapper output instead of reimplemnting stuff in HM (notwithstanding rtp
changes that are not needed in HM).
This is necessary to keep the provider configuration available after
this change NixOS/nixpkgs#487390

Also updated test to reflect ruby disabling
wcarlsen pushed a commit to wcarlsen/home-manager that referenced this pull request May 1, 2026
now that home-manager always generates an init.lua we can take the
wrapper output instead of reimplemnting stuff in HM (notwithstanding rtp
changes that are not needed in HM).
This is necessary to keep the provider configuration available after
this change NixOS/nixpkgs#487390

Also updated test to reflect ruby disabling
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: vim Advanced text editor 8.has: changelog This PR adds or changes release notes 8.has: documentation This PR adds or changes documentation 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 12.approvals: 2 This PR was reviewed and approved by two persons.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants