mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-20 16:15:43 +02:00
modules/performance/combine-plugins: propagate lua dependencies
Plugins from luarocks (e.g. telescope-nvim) have dependencies specified in propagatedBuildInputs. These dependencies are not added as plugins in Nvim runtime. They are added to LUA_PATH env var for wrapped neovim. This commit collects all propagatedBuildInputs from input plugin list and puts them in the combined plugin. Note that such dependencies are never combined, because they are not plugins.
This commit is contained in:
parent
57e19ec3ec
commit
f28d384ab5
2 changed files with 71 additions and 17 deletions
|
@ -28,24 +28,38 @@ let
|
|||
(builtins.concatMap (f: f ps))
|
||||
];
|
||||
|
||||
# propagatedBuildInputs contain lua dependencies
|
||||
propagatedBuildInputs = lib.pipe pluginsToCombine [
|
||||
(builtins.catAttrs "plugin")
|
||||
(builtins.catAttrs "propagatedBuildInputs")
|
||||
builtins.concatLists
|
||||
lib.unique
|
||||
];
|
||||
|
||||
# Combined plugin
|
||||
combinedPlugin = pkgs.vimUtils.toVimPlugin (
|
||||
pkgs.buildEnv {
|
||||
combinedPlugin =
|
||||
lib.pipe
|
||||
{
|
||||
name = "plugin-pack";
|
||||
paths = overriddenPlugins;
|
||||
inherit pathsToLink;
|
||||
|
||||
# Remove empty directories and activate vimGenDocHook
|
||||
# TODO: figure out why we are running the `preFixup` hook in `postBuild`
|
||||
# buildEnv uses runCommand under the hood. runCommand doesn't run any build phases.
|
||||
# To run custom commands buildEnv takes postBuild argument.
|
||||
# fixupPhase is used for propagating build inputs and to trigger vimGenDocHook
|
||||
postBuild = ''
|
||||
find $out -type d -empty -delete
|
||||
runHook preFixup
|
||||
fixupPhase
|
||||
'';
|
||||
passthru = {
|
||||
inherit python3Dependencies;
|
||||
};
|
||||
}
|
||||
);
|
||||
[
|
||||
pkgs.buildEnv
|
||||
pkgs.vimUtils.toVimPlugin
|
||||
(drv: drv.overrideAttrs { inherit propagatedBuildInputs; })
|
||||
];
|
||||
|
||||
# Combined plugin configs
|
||||
combinedConfig = lib.pipe pluginsToCombine [
|
||||
|
|
|
@ -69,6 +69,17 @@ let
|
|||
pluginWithPyDeps3 = mkPlugin "plugin-with-py-deps-3" {
|
||||
passthru.python3Dependencies = ps: [ ps.requests ];
|
||||
};
|
||||
# Plugins with Lua dependencies
|
||||
ensureDep =
|
||||
drv: dep:
|
||||
drv.overrideAttrs (prev: {
|
||||
propagatedBuildInputs = lib.unique (
|
||||
prev.propagatedBuildInputs or [ ] ++ [ prev.passthru.lua.pkgs.${dep} ]
|
||||
);
|
||||
});
|
||||
pluginWithLuaDeps1 = ensureDep pkgs.vimPlugins.telescope-nvim "plenary-nvim";
|
||||
pluginWithLuaDeps2 = ensureDep pkgs.vimPlugins.nvim-cmp "plenary-nvim";
|
||||
pluginWithLuaDeps3 = ensureDep pkgs.vimPlugins.gitsigns-nvim "nui-nvim";
|
||||
in
|
||||
{
|
||||
# Test basic functionality
|
||||
|
@ -222,6 +233,35 @@ in
|
|||
];
|
||||
};
|
||||
|
||||
# Test that plugin lua dependencies are handled
|
||||
lua-dependencies =
|
||||
{ config, ... }:
|
||||
{
|
||||
performance.combinePlugins.enable = true;
|
||||
extraPlugins = [
|
||||
simplePlugin1
|
||||
# Duplicated plenary-nvim dependency
|
||||
pluginWithLuaDeps1
|
||||
pluginWithLuaDeps2
|
||||
# nui-nvim dependency
|
||||
pluginWithLuaDeps3
|
||||
];
|
||||
extraConfigLuaPost = ''
|
||||
-- All packages and its dependencies are importable
|
||||
require("telescope")
|
||||
require("plenary")
|
||||
require("cmp")
|
||||
require("gitsigns")
|
||||
require("nui.popup")
|
||||
'';
|
||||
assertions = [
|
||||
{
|
||||
assertion = pluginCount config.build.nvimPackage config.build.extraFiles "start" == 1;
|
||||
message = "More than one plugin is defined in packpathDirs.";
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
# Test that optional plugins are handled
|
||||
optional-plugins =
|
||||
{ config, ... }:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue