From f21d8ebbc959e5da6fbda105ff47e334f058ac06 Mon Sep 17 00:00:00 2001 From: Matthieu Coudron <886074+teto@users.noreply.github.com> Date: Wed, 1 Apr 2026 22:27:03 +0200 Subject: [PATCH] neovim: test pure lua dependencies (#8991) a revert of https://github.com/nix-community/home-manager/pull/8959 since we now relies on nixpkgs wrapper for that. adding a test to avoid regressions. Choosing telescope as starting point is https://github.com/nix-community/home-manager/issues/8787 I find the nmt test setup lacking: it doesnt set $PATH or $HOME (nvim will error when it can't write into $HOME). --- modules/programs/neovim.nix | 3 +-- .../modules/programs/neovim/plugin-config.nix | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/modules/programs/neovim.nix b/modules/programs/neovim.nix index 5f5a06bd..a0122182 100644 --- a/modules/programs/neovim.nix +++ b/modules/programs/neovim.nix @@ -441,8 +441,8 @@ in withNodeJs = cfg.withNodeJs || cfg.coc.enable; plugins = nixpkgsCompatiblePlugins; - extraLuaPackages = lp: cfg.extraLuaPackages lp ++ vimPackageInfo.luaDependencies; inherit (cfg) + extraLuaPackages extraName withPython3 withRuby @@ -521,7 +521,6 @@ in '' else null; - in lib.mkMerge [ (lib.mkIf wrapperHasUserConfig ( diff --git a/tests/modules/programs/neovim/plugin-config.nix b/tests/modules/programs/neovim/plugin-config.nix index 7ac11996..bd234e95 100644 --- a/tests/modules/programs/neovim/plugin-config.nix +++ b/tests/modules/programs/neovim/plugin-config.nix @@ -34,6 +34,10 @@ lib.mkIf config.test.enableBig { # to test passthru.initLua is taken into account plugin = unicode-vim; } + { + # test pure lua dependencies: telescope relies on the lua version of plenary + plugin = telescope-nvim; + } ]; extraLuaPackages = ps: [ ps.luautf8 ]; }; @@ -48,15 +52,26 @@ lib.mkIf config.test.enableBig { in '' vimout=$(mktemp) + + export PATH="$TESTED/home-path/bin:$PATH" + export HOME=$TMPDIR/hm-user + initLua="$TESTED/home-files/.config/nvim/init.lua" + echo "redir >> /dev/stdout | echo g:hmExtraConfig | echo g:hmPlugins | echo g:Unicode_data_directory | redir END" \ - | ${pkgs.neovim}/bin/nvim -es -u "$TESTED/home-files/.config/nvim/init.lua" \ + | nvim -es -i NONE -u "$initLua" \ > "$vimout" || true + assertFileContains "$vimout" "HM_EXTRA_CONFIG" assertFileContains "$vimout" "HM_PLUGINS_CONFIG" # testing that unicode-vim's value is echoed assertFileContains "$vimout" "autoload/unicode" - initLua="$TESTED/home-files/.config/nvim/init.lua" + # check telescope can find plenary/does not trigger any error + if ! nvim -V3log.txt -i NONE -es -u "$initLua" -c "lua require('plenary') " -c "quit"; then + fail "Could not require the 'plenary' dependency pulled by telescope.nvim" + cat log.txt + fi + assertFileContent $(normalizeStorePaths "$initLua") ${./plugin-config.expected} # Verify generatedConfigs evaluated properly (issue #8371)