From d309a0b9e971d8b765dff98b5b1c52a8a7e9932a Mon Sep 17 00:00:00 2001 From: Colin Heffernan <92215668+colin-heffernan@users.noreply.github.com> Date: Sun, 18 Sep 2022 21:19:11 +0000 Subject: [PATCH] neovimUtils: put optional plugins in incorrect folder all plugins ended up in "start". Also adds a test --- .../editors/neovim/tests/default.nix | 40 +++++++++++++++++++ pkgs/applications/editors/neovim/utils.nix | 4 +- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/pkgs/applications/editors/neovim/tests/default.nix b/pkgs/applications/editors/neovim/tests/default.nix index 14b6bdf2e375..660a86903555 100644 --- a/pkgs/applications/editors/neovim/tests/default.nix +++ b/pkgs/applications/editors/neovim/tests/default.nix @@ -222,4 +222,44 @@ rec { export HOME=$TMPDIR ${nvimWithLuaPackages}/bin/nvim -i NONE --noplugin -es ''; + + # nixpkgs should install optional packages in the opt folder + nvim_with_opt_plugin = neovim.override { + extraName = "-with-opt-plugin"; + configure.packages.opt-plugins = with pkgs.vimPlugins; { + opt = [ + (dashboard-nvim.overrideAttrs(old: { pname = old.pname + "-unique-for-tests-please-dont-use-opt"; })) + ]; + }; + configure.customRC = '' + " Load all autoloaded plugins + packloadall + + " Try to run Dashboard, and throw if it succeeds + try + Dashboard + echo "Dashboard found, throwing error" + cquit 1 + catch /^Vim\%((\a\+)\)\=:E492/ + echo "Dashboard not found" + endtry + + " Load Dashboard as an optional + packadd dashboard-nvim-unique-for-tests-please-dont-use-opt + + " Try to run Dashboard again, and throw if it fails + try + Dashboard + echo "Dashboard found" + catch /^Vim\%((\a\+)\)\=:E492/ + echo "Dashboard not found, throwing error" + cquit 1 + endtry + ''; + }; + + run_nvim_with_opt_plugin = runTest nvim_with_opt_plugin '' + export HOME=$TMPDIR + ${nvim_with_opt_plugin}/bin/nvim -i NONE +quit! -e + ''; }) diff --git a/pkgs/applications/editors/neovim/utils.nix b/pkgs/applications/editors/neovim/utils.nix index 2af7ffb43943..feb5f9637ba1 100644 --- a/pkgs/applications/editors/neovim/utils.nix +++ b/pkgs/applications/editors/neovim/utils.nix @@ -170,8 +170,8 @@ let throw "The neovim legacy wrapper doesn't support configure.plug anymore, please setup your plugins via 'configure.packages' instead" else lib.flatten (lib.mapAttrsToList genPlugin (configure.packages or {})); - genPlugin = packageName: {start ? [], opt?[]}: - start ++ opt; + genPlugin = packageName: {start ? [], opt ? []}: + start ++ (map (p: { plugin = p; optional = true; }) opt); res = makeNeovimConfig { inherit withPython3;