From b0491fe55680bd19be8e74847969dad9d7784658 Mon Sep 17 00:00:00 2001 From: teto <886074+teto@users.noreply.github.com> Date: Sat, 17 Jan 2026 18:53:26 +0100 Subject: [PATCH] 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. --- modules/programs/neovim.nix | 10 ++++++++++ tests/modules/programs/neovim/plugin-config.expected | 2 ++ 2 files changed, 12 insertions(+) diff --git a/modules/programs/neovim.nix b/modules/programs/neovim.nix index 086390fd..9de9ad9f 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 d6bed070..8599141a 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