Neovim changes in nixpkgs (aka stopped loading plugins from your HOME)

For neovim users tracking nixpkgs-unstable, you might have been surprised seeing that plugins in your $XDG_CONFIG_HOME/nvim were not loaded anymore, here is the culprit: , ie., the neovim wrapper now passes the “–clean” flag (“Mimic a fresh install of Nvim. Skip loading non-builtin plugins and shada (viminfo) file.”) to neovim to provide better reproducibility.

The home-manager module is not affected by it since it doesn’t wrap neovim (home-manger writes the generated neovim config in XDG_CONFIG_HOME/nvim/init.vim , i.e., where it’s expected so no need to wrap).

In nixpkgs, the wrapping is enabled if you start installing packages, another solution can be to use “neovim-unwrapped” (a raw neovim) rather than “neovim” (a nix derivation that tries to be smart, sometimes too smart for your own good).

The (neo)vim configuration can be a bit complex to setup and one of my wishes is to simplify it before the next nixos release. A big change I would like to do is to change the names so that neovim-unwrapped becomes neovim and neovim becomes something else like “wrappedNeovim” e.g., make it clear that it’s not the pure package. It’s probably going to break many configs but I find it a better experience to have advanced-wrappers being opt-in rather than opt-out.


Why I would love the idea of perfectly hermetic neovim configuration, I think a it will lead to breakage of several plugins.

For example, the nvim-treesitter plugin (which I feel is quite important in the ecosystem) will install grammars into ${stdpath("data")}/site which is not included anymore with the --clean flag. I think a lot of plugins which keep state will be using XDG_DATA_HOME and are going to have issues.

Another concern is that, according to a nvim-treesitter contributor:

nvim --clean is a debug option introduced for reproducible bug reports. it should not be used in normal operation

If that’s the case, we might have issues predicting what is going to get included under that flag, whether it will break other things in the future.

This might be a noob question but how do I get install lastest versions of neovim without having nix populate the ~/.config/nvim directory so that I can stow and manage the config myself. The fact to recompile my nvim.nix in order to make changes to my neovim config is really annoying and slow. Sometimes home-manager switch straight up compiles neovim again. BTW I am neovim overlay to install neovim. Other ways I have go about installing neovim never seems to work.

I’d suggest you to create a seperate thread for your questions, to keep this thread focused on teto’ findings and ideas

1 Like

you can install nvim-treesitter via nix.

hum one issue with --clean is that it stops loading shada (shared data) files . I did not realize it when merging that and it’s indeed an issue. One workaround could be to run --noplugin and load the builtin plugins via the wrapper.

@jedimaster if you are using an overlay then it makes sense that you rebuild neovim from time to time, unless you have some cache configured. If you dont want nix to be involved with your config at all, just install neovim-unwrapped.

1 Like

Thank you for the tip. I definitely agree with your suggestion about making neovim unwrapped the default and the wrappedNeovim the opt in. I appreciate your help.

Note: this change was reverted because --clean actually prevented shada from being loaded. I think we will try to enforce purity, via another approach but we’ll better announce and test it ! the current behavior doesn’t bother me much so I dont think the change will come from me though.

1 Like