diff --git a/pkgs/applications/editors/neovim/default.nix b/pkgs/applications/editors/neovim/default.nix index f36009afc69a..9e5901cb9416 100644 --- a/pkgs/applications/editors/neovim/default.nix +++ b/pkgs/applications/editors/neovim/default.nix @@ -50,6 +50,8 @@ in dontFixCmake = true; + inherit lua; + buildInputs = [ gperf libtermkey diff --git a/pkgs/applications/editors/neovim/tests.nix b/pkgs/applications/editors/neovim/tests.nix index f9d0d659b73c..5f4cda714a67 100644 --- a/pkgs/applications/editors/neovim/tests.nix +++ b/pkgs/applications/editors/neovim/tests.nix @@ -132,4 +132,15 @@ rec { extraName = "-pathogen"; configure.pathogen.pluginNames = [ "vim-nix" ]; }; + + nvimWithLuaPackages = wrapNeovim2 "with-lua-packages" (makeNeovimConfig { + extraLuaPackages = ps: [ps.mpack]; + customRC = '' + lua require("mpack") + ''; + }); + + nvim_with_lua_packages = runTest nvimWithLuaPackages '' + ${nvimWithLuaPackages}/bin/nvim -i NONE --noplugin -es + ''; }) diff --git a/pkgs/applications/editors/neovim/utils.nix b/pkgs/applications/editors/neovim/utils.nix index c753d2cca2c1..837c9a79ffe8 100644 --- a/pkgs/applications/editors/neovim/utils.nix +++ b/pkgs/applications/editors/neovim/utils.nix @@ -28,6 +28,8 @@ let , extraPython3Packages ? (_: [ ]) , withNodeJs ? false , withRuby ? true + /* the function you would have passed to lua.withPackages */ + , extraLuaPackages ? (_: [ ]) # expects a list of plugin configuration # expects { plugin=far-vim; config = "let g:far#source='rg'"; optional = false; } @@ -76,6 +78,8 @@ let ++ (extraPython3Packages ps) ++ (lib.concatMap (f: f ps) pluginPython3Packages)); + lua = neovim-unwrapped.lua; + luaEnv = lua.withPackages(ps: extraLuaPackages ps); # Mapping a boolean argument to a key that tells us whether to add or not to # add to nvim's 'embedded rc' this: @@ -110,6 +114,9 @@ let "--set" "GEM_HOME" "${rubyEnv}/${rubyEnv.ruby.gemPath}" ] ++ lib.optionals (binPath != "") [ "--suffix" "PATH" ":" binPath + ] ++ lib.optionals (luaEnv != null) [ + "--prefix" "LUA_PATH" ";" "${luaEnv}/share/lua/${lua.luaversion}/?.lua" + "--prefix" "LUA_CPATH" ";" "${luaEnv}/lib/lua/${lua.luaversion}/?.so" ]; @@ -123,6 +130,7 @@ let inherit neovimRcContent; inherit manifestRc; inherit python3Env; + inherit luaEnv; inherit withNodeJs; } // lib.optionalAttrs withRuby { inherit rubyEnv; @@ -143,6 +151,8 @@ let , extraPythonPackages ? (_: []) /* the function you would have passed to python.withPackages */ , withPython3 ? true, extraPython3Packages ? (_: []) + /* the function you would have passed to lua.withPackages */ + , extraLuaPackages ? (_: []) , withNodeJs ? false , withRuby ? true , vimAlias ? false @@ -159,6 +169,7 @@ let res = makeNeovimConfig { inherit withPython3; extraPython3Packages = compatFun extraPython3Packages; + inherit extraLuaPackages; inherit withNodeJs withRuby viAlias vimAlias; inherit configure; inherit extraName;