link the packpath in expected folder so that even unwrapped neovim can pick home-manager's plugins.
I sometimes need to run neovim not wrapped/configured by nix (when
developing neovim or when other projects bring their own neovim in
PATH). Currently they dont find plugins installed by home-manager in the
cases where packpath is not set to the generated nix packpath directory.
With this change, neovim can discover HM-installed plugins by itself.
Assigning to `programs.neovim.extraLuaPackages` a function taking a lua package set as input
and returning a list of packages, as described in the documentation,
threw an error because the rest of the code assumed that the value was always a plain list.
Using `lib.types.coercedTo`, we can accept such functions, as per the documentation,
as well as plain lists, which we then convert to a function ignoring its input argument.
We print a warning when a plain list is assigned, since the function
form is preferred, as it ensures that the right lua package set is used.
For the lua packages, we also get the lua package set from the
finalPackage, to make sure that we are always using the same package set
as the actual unwrapped neovim package being built.
For `programs.neovim.extraPythonPackages` I did the same.
I updated the test case so that we test both ways of setting these options.
The previous version linked the file into home, then sourced that. Since
nothing else expects that file to be there, this is unnecessary.
Additionally, doing so made it impossible to test a built config without
switching, e.g. using `XDG_CONFIG_HOME=… nvim` or `nvim -u`. This
remedies that, at least for this particular reference.
To test this, change from asserting contents of the config file to
actually starting nvim, outputting sentinel values, and then asserting
their values are present. This way it’s tested that nvim loaded the
config, rather than that some config is in a specific place.
This is all in one commit as the test, as written now, would not have
worked before since the previously hard-coded home path was not an
actual file in the test environment.
We change the current logic: instead of writing an init.vim which loads
lua/init-home-manager.lua, we write an init.lua that sources init.vim
This commit also avoids writing any of these files if the plugins have
no config.
everything is now covered by other settings that are more user friendly
than this big opaque attrset.
Also 'configure' wont do anything with nixpkgs-unstable the way HM
configures neovim. so no need to keep it, the deprecation warning is > 1
year old.
Plugins now accept a "type" element describing the language (viml, lua
, teal, fennel, ...) in which
they are configured.
The configuration of the different plugins is aggregated per language
and made available as a key in the attribute set `programs.neovim.generatedConfigs`
For instance if you want to configure a lua package:
```
programs.neovim.plugins = [
{
plugin = packer-nvim;
type = "lua";
config = ''
require('packer').init({
luarocks = {
python_cmd = 'python' -- Set the python command to use for running hererocks
},
})
'';
}
]
```
and you can save the generated lua config to a file via
```
xdg.configFile = {
"nvim/init.generated.lua".text = config.programs.neovim.generatedConfigs.lua;
};
```
Expose the generated viml config, this has 2 advantages:
1/ user can choose to write the generated config to a file of its choice
2/ the user can prepend/append to the config before writing it
xdg.configFile."nvim/init.vim".text = ''
" prepend some config
${programs.neovim.generatedConfigViml}
" append some config
'';
NOTE: this was already possible with
xdg.configFile."nvim/init.vim" = mkMerge [
(mkBefore {
text = ''
" prepend some config
'';
})
(mkAfter {
text = ''
" append some config
'';
})
]
This adds two new options: 'programs.neovim.coc.{enable,settings}`.
These settings offer a simple interface over `xdg.configFile."nvim/coc-settings.json`,
using the standard Nix' syntax instead of a multiline string.
When installing plugins, Home Manager expects plugins (packages) to have
a `pname` attribute.
This is not always the case, so fallback to `name` if `pname` is unset.
The `configure` option is not type checked and an artifact of how
nixpkgs is implemented.
We now have the equivalent options in home-manager and managing
interactions between the 2 systems complexifies maintainance of the
module.
Please use the other options at your disposal:
configure.packages.*.opt -> programs.neovim.plugins = [ { plugin = ...; optional = true; }]
configure.packages.*.start -> programs.neovim.plugins = [ { plugin = ...; }]
configure.customRC -> programs.neovim.extraConfig
* neovim: write config in $XDG_CONFIG_HOME/init.vim
instead of wrapping the configuration, which has sideeffects
https://github.com/NixOS/nixpkgs/issues/55376
* fix: update test accordingly
* neovim: allow setting init.vim config alongside plugins
* neovim: add test for neovim plugins
* neovim: make pluginWithConfigType a have type submodule
The `programs.neovim.configure` option is consistent with NixOS's
`wrapNeovim` and offers features not supported by the `extraConfig`
and `plugins` option pair.
Closes#971