neovim: move LUA_(C)PATH setup from wrapping to init.lua

so alternative GUIs can find lua dependencies that are not plugins (for instance nio).
Some plugins depend on lua packages that are not vim plugins and thus
become "invisible" to nixpkgs as it stands.
For now they need to be specified manually via `extraLuaPackages` but
hopefully we can autodiscover those in nixpkgs.
This commit is contained in:
teto 2026-01-17 18:53:26 +01:00 committed by Matthieu Coudron
parent ec0247a7a1
commit b0491fe556
2 changed files with 12 additions and 0 deletions

View file

@ -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

View file

@ -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