From 7e1ae5e8bbb9f6733c50aebdba9a242ee8d61d04 Mon Sep 17 00:00:00 2001 From: "Matthieu C." <886074+teto@users.noreply.github.com> Date: Wed, 12 Jun 2024 15:22:03 +0200 Subject: [PATCH] neovim: wrap LUA_PATH and LUA_CPATH As described in https://github.com/NixOS/nixpkgs/issues/318925, lua neovim plugin dependencies are not visible from neovim. This calls the lua hook on the neovim packpack dir with the plugins. The hook scans the propagated-build-input files (generated via neovimUtils.packDir) and adds them to LUA_PATH / LUA_CPATH when necessary. We then wrap neovim with these values LUA_PATH prefixed with those values --- pkgs/applications/editors/neovim/wrapper.nix | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/pkgs/applications/editors/neovim/wrapper.nix b/pkgs/applications/editors/neovim/wrapper.nix index 14d5c51319f5..d86de46c8738 100644 --- a/pkgs/applications/editors/neovim/wrapper.nix +++ b/pkgs/applications/editors/neovim/wrapper.nix @@ -13,6 +13,9 @@ neovim-unwrapped: let + # inherit interpreter from neovim + lua = neovim-unwrapped.lua; + wrapper = { extraName ? "" # should contain all args but the binary. Can be either a string or list @@ -61,7 +64,6 @@ let # vim accepts a limited number of commands so we join them all [ "--add-flags" ''--cmd "lua ${providerLuaRc}"'' - # (lib.intersperse "|" hostProviderViml) ] ++ lib.optionals (packpathDirs.myNeovimPackages.start != [] || packpathDirs.myNeovimPackages.opt != []) [ "--add-flags" ''--cmd "set packpath^=${finalPackdir}"'' @@ -165,7 +167,17 @@ let + '' rm $out/bin/nvim touch $out/rplugin.vim - makeWrapper ${lib.escapeShellArgs finalMakeWrapperArgs} ${wrapperArgsStr} + + echo "Looking for lua dependencies..." + source ${lua}/nix-support/utils.sh + + _addToLuaPath "${finalPackdir}" + + echo "LUA_PATH towards the end of packdir: $LUA_PATH" + + makeWrapper ${lib.escapeShellArgs finalMakeWrapperArgs} ${wrapperArgsStr} \ + --prefix LUA_PATH ';' "$LUA_PATH" \ + --prefix LUA_CPATH ';' "$LUA_CPATH" ''; buildPhase = ''