neovim: move python3 deps computation to module
this should be a simple refactor as part of self-documenting neovim interface. The type of `pluginPython3Packages` might be too restrictive compared to how it's used in the while (with null ?). Hopefully it's ok.
This commit is contained in:
@@ -13,7 +13,7 @@ let
|
||||
optional = false;
|
||||
};
|
||||
in
|
||||
map (x: defaultPlugin // (if (x ? plugin) then x else { plugin = x; })) plugins;
|
||||
map (x: defaultPlugin // (if x ? plugin then x else { plugin = x; })) plugins;
|
||||
|
||||
pluginWithConfigType =
|
||||
with lib;
|
||||
@@ -78,17 +78,26 @@ in
|
||||
|
||||
userPluginViml = lib.mkOption {
|
||||
readOnly = true;
|
||||
type = lib.types.listOf (lib.types.lines);
|
||||
type = lib.types.listOf lib.types.lines;
|
||||
description = ''
|
||||
The viml config set by the user.
|
||||
'';
|
||||
};
|
||||
|
||||
pluginPython3Packages = lib.mkOption {
|
||||
readOnly = true;
|
||||
type = lib.types.listOf (lib.types.functionTo (lib.types.listOf lib.types.package));
|
||||
example = lib.literalExpression "[ (ps: [ ps.python-language-server ]) ]";
|
||||
description = ''
|
||||
Packages required by the plugins to work with the python3 provider.
|
||||
'';
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
config =
|
||||
let
|
||||
pluginsNormalized = normalizePlugins config.plugins;
|
||||
pluginsNormalized = config.plugins;
|
||||
in
|
||||
{
|
||||
pluginAdvisedLua =
|
||||
@@ -111,5 +120,7 @@ in
|
||||
userPluginViml = lib.foldl (
|
||||
acc: p: if p.config != null then acc ++ [ p.config ] else acc
|
||||
) [ ] pluginsNormalized;
|
||||
|
||||
pluginPython3Packages = map (plugin: plugin.python3Dependencies or (_: [ ])) pluginsNormalized;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -99,24 +99,19 @@ let
|
||||
inherit plugins;
|
||||
};
|
||||
|
||||
pluginsNormalized = normalizePlugins plugins;
|
||||
pluginsNormalized = checked_cfg.plugins;
|
||||
|
||||
vimPackage = normalizedPluginsToVimPackage pluginsNormalized;
|
||||
|
||||
getDeps = attrname: map (plugin: plugin.${attrname} or (_: [ ]));
|
||||
|
||||
requiredPlugins = vimUtils.requiredPluginsForPackage vimPackage;
|
||||
pluginPython3Packages = getDeps "python3Dependencies" requiredPlugins;
|
||||
in
|
||||
{
|
||||
# plugins' python dependencies
|
||||
inherit pluginPython3Packages;
|
||||
|
||||
# viml config set by the user along with the plugin
|
||||
inherit (checked_cfg)
|
||||
userPluginViml
|
||||
runtimeDeps
|
||||
pluginAdvisedLua
|
||||
pluginPython3Packages
|
||||
;
|
||||
|
||||
# A Vim "package", see ':h packages'
|
||||
|
||||
Reference in New Issue
Block a user