diff --git a/modules/programs/neovim.nix b/modules/programs/neovim.nix index 086390fdbbeb..9de9ad9fdb8d 100644 --- a/modules/programs/neovim.nix +++ b/modules/programs/neovim.nix @@ -505,9 +505,18 @@ in advisedLua = foldedLuaBlock "home-manager generated: plugin config advised in nixpkgs" ( lib.concatStringsSep "\n" vimPackageInfo.pluginAdvisedLua ); + + generatedLuaPath = lib.concatMapStringsSep ";" luaPackages.getLuaPath resolvedExtraLuaPackages; + generatedLuaCPath = lib.concatMapStringsSep ";" luaPackages.getLuaCPath resolvedExtraLuaPackages; in lib.mkMerge [ + (lib.mkIf ( + resolvedExtraLuaPackages != [ ] + ) ''package.path = "${generatedLuaPath}".. ";" .. package.path'') + (lib.mkIf ( + resolvedExtraLuaPackages != [ ] + ) ''package.cpath = "${generatedLuaCPath}".. ";" .. package.cpath'') (lib.mkIf (advisedLua != null) (lib.mkOrder 510 advisedLua)) (lib.mkIf (wrappedNeovim'.initRc != "") ( lib.mkBefore "vim.cmd [[source ${pkgs.writeText "nvim-init-home-manager.vim" wrappedNeovim'.initRc}]]" @@ -515,6 +524,7 @@ in (lib.mkIf (lib.hasAttr "lua" cfg.generatedConfigs) ( lib.mkAfter (foldedLuaBlock "user-associated plugin config" cfg.generatedConfigs.lua) )) + ]; # link the packpath in expected folder so that even unwrapped neovim can pick diff --git a/tests/modules/programs/neovim/plugin-config.expected b/tests/modules/programs/neovim/plugin-config.expected index d6bed070cd1a..8599141a0ece 100644 --- a/tests/modules/programs/neovim/plugin-config.expected +++ b/tests/modules/programs/neovim/plugin-config.expected @@ -1,4 +1,6 @@ vim.cmd [[source /nix/store/00000000000000000000000000000000-nvim-init-home-manager.vim]] +package.path = "/nix/store/00000000000000000000000000000000-luajit2.1-luautf8/share/lua/5.1/?.lua;/nix/store/00000000000000000000000000000000-luajit2.1-luautf8/share/lua/5.1/?/init.lua".. ";" .. package.path +package.cpath = "/nix/store/00000000000000000000000000000000-luajit2.1-luautf8/lib/lua/5.1/?.so".. ";" .. package.cpath -- user-associated plugin config {{{ function HM_PLUGIN_LUA_CONFIG () end