diff --git a/modules/programs/neovim.nix b/modules/programs/neovim.nix index 4752100ea..3e801c8e0 100644 --- a/modules/programs/neovim.nix +++ b/modules/programs/neovim.nix @@ -241,7 +241,18 @@ in { }; }; - config = mkIf cfg.enable { + config = let + extraMakeWrapperArgs = lib.optionalString (cfg.extraPackages != [ ]) + ''--prefix PATH : "${lib.makeBinPath cfg.extraPackages}"''; + neovimConfig = pkgs.neovimUtils.makeNeovimConfig { + inherit (cfg) + extraPython3Packages withPython3 extraPythonPackages withPython + withNodeJs withRuby viAlias vimAlias; + configure = cfg.configure // moduleConfigure; + plugins = cfg.plugins; + }; + + in mkIf cfg.enable { assertions = [{ assertion = cfg.configure == { } || moduleConfigure == { }; message = "The programs.neovim option configure is mutually exclusive" @@ -250,14 +261,12 @@ in { home.packages = [ cfg.finalPackage ]; - programs.neovim.finalPackage = pkgs.wrapNeovim cfg.package { - inherit (cfg) - extraPython3Packages withPython3 extraPythonPackages withPython - withNodeJs withRuby viAlias vimAlias; - - extraMakeWrapperArgs = extraMakeWrapperArgs; - configure = cfg.configure // moduleConfigure; - }; + xdg.configFile."nvim/init.vim".text = neovimConfig.neovimRcContent; + programs.neovim.finalPackage = pkgs.wrapNeovimUnstable cfg.package + (neovimConfig // { + wrapperArgs = (lib.escapeShellArgs neovimConfig.wrapperArgs) + " " + + extraMakeWrapperArgs; + }); programs.bash.shellAliases = mkIf cfg.vimdiffAlias { vimdiff = "nvim -d"; }; programs.fish.shellAliases = mkIf cfg.vimdiffAlias { vimdiff = "nvim -d"; }; diff --git a/tests/modules/programs/neovim/plugin-config.nix b/tests/modules/programs/neovim/plugin-config.nix index 60edaee82..4c96fa784 100644 --- a/tests/modules/programs/neovim/plugin-config.nix +++ b/tests/modules/programs/neovim/plugin-config.nix @@ -23,9 +23,8 @@ with lib; }; nmt.script = '' - vimrc=$(grep -Po "(?<=-u )[^ ]*" < "${ - builtins.toJSON config.programs.neovim.finalPackage - }/bin/nvim") + vimrc="$TESTED/home-files/.config/nvim/init.vim" + assertFileExists home-files/.config/nvim/init.vim # We need to remove the unkown store paths in the config TESTED="" assertFileContent \ <( ${pkgs.perl}/bin/perl -pe "s|\Q$NIX_STORE\E/[a-z0-9]{32}-|$NIX_STORE/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-|g" < "$vimrc"