vim-plugins: Add infrastructure for python[3]Dependencies.
This allows vim plugins to specify python dependencies required at runtime, and they will be added to the python environment.
This commit is contained in:
parent
6018cf4a69
commit
dcab427908
@ -53,18 +53,24 @@ let
|
|||||||
rubyWrapper = ''--suffix PATH : \"${rubyEnv}/bin\" '' +
|
rubyWrapper = ''--suffix PATH : \"${rubyEnv}/bin\" '' +
|
||||||
''--suffix GEM_HOME : \"${rubyEnv}/${rubyEnv.ruby.gemPath}\" '';
|
''--suffix GEM_HOME : \"${rubyEnv}/${rubyEnv.ruby.gemPath}\" '';
|
||||||
|
|
||||||
|
pluginPythonPackages = builtins.concatLists
|
||||||
|
(map ({ pythonDependencies ? [], ...}: pythonDependencies)
|
||||||
|
(vimUtils.requiredPlugins configure));
|
||||||
pythonEnv = pythonPackages.python.buildEnv.override {
|
pythonEnv = pythonPackages.python.buildEnv.override {
|
||||||
extraLibs = (
|
extraLibs = (
|
||||||
if withPyGUI
|
if withPyGUI
|
||||||
then [ pythonPackages.neovim_gui ]
|
then [ pythonPackages.neovim_gui ]
|
||||||
else [ pythonPackages.neovim ]
|
else [ pythonPackages.neovim ]
|
||||||
) ++ extraPythonPackages;
|
) ++ extraPythonPackages ++ pluginPythonPackages;
|
||||||
ignoreCollisions = true;
|
ignoreCollisions = true;
|
||||||
};
|
};
|
||||||
pythonWrapper = ''--cmd \"let g:python_host_prog='$out/bin/nvim-python'\" '';
|
pythonWrapper = ''--cmd \"let g:python_host_prog='$out/bin/nvim-python'\" '';
|
||||||
|
|
||||||
|
pluginPython3Packages = builtins.concatLists
|
||||||
|
(map ({ python3Dependencies ? [], ...}: python3Dependencies)
|
||||||
|
(vimUtils.requiredPlugins configure));
|
||||||
python3Env = python3Packages.python.buildEnv.override {
|
python3Env = python3Packages.python.buildEnv.override {
|
||||||
extraLibs = [ python3Packages.neovim ] ++ extraPython3Packages;
|
extraLibs = [ python3Packages.neovim ] ++ extraPython3Packages ++ pluginPython3Packages;
|
||||||
ignoreCollisions = true;
|
ignoreCollisions = true;
|
||||||
};
|
};
|
||||||
python3Wrapper = ''--cmd \"let g:python3_host_prog='$out/bin/nvim-python3'\" '';
|
python3Wrapper = ''--cmd \"let g:python3_host_prog='$out/bin/nvim-python3'\" '';
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
, xkb_switch, rustracerd, fzf
|
, xkb_switch, rustracerd, fzf
|
||||||
, python3, boost, icu
|
, python3, boost, icu
|
||||||
, ycmd
|
, ycmd
|
||||||
|
, pythonPackages, python3Packages
|
||||||
, Cocoa ? null
|
, Cocoa ? null
|
||||||
}:
|
}:
|
||||||
|
|
||||||
|
@ -150,6 +150,10 @@ vim_with_plugins can be installed like any other application within Nix.
|
|||||||
let
|
let
|
||||||
inherit (stdenv) lib;
|
inherit (stdenv) lib;
|
||||||
|
|
||||||
|
toNames = x:
|
||||||
|
if builtins.isString x then [x]
|
||||||
|
else (lib.optional (x ? name) x.name)
|
||||||
|
++ (x.names or []);
|
||||||
findDependenciesRecursively = {knownPlugins, names}:
|
findDependenciesRecursively = {knownPlugins, names}:
|
||||||
|
|
||||||
let depsOf = name: (builtins.getAttr name knownPlugins).dependencies or [];
|
let depsOf = name: (builtins.getAttr name knownPlugins).dependencies or [];
|
||||||
@ -211,11 +215,6 @@ let
|
|||||||
(let
|
(let
|
||||||
knownPlugins = vam.knownPlugins or vimPlugins;
|
knownPlugins = vam.knownPlugins or vimPlugins;
|
||||||
|
|
||||||
toNames = x:
|
|
||||||
if builtins.isString x then [x]
|
|
||||||
else (lib.optional (x ? name) x.name)
|
|
||||||
++ (x.names or []);
|
|
||||||
|
|
||||||
names = findDependenciesRecursively { inherit knownPlugins; names = lib.concatMap toNames vam.pluginDictionaries; };
|
names = findDependenciesRecursively { inherit knownPlugins; names = lib.concatMap toNames vam.pluginDictionaries; };
|
||||||
|
|
||||||
# Vim almost reads JSON, so eventually JSON support should be added to Nix
|
# Vim almost reads JSON, so eventually JSON support should be added to Nix
|
||||||
@ -412,6 +411,19 @@ rec {
|
|||||||
configurePhase =":";
|
configurePhase =":";
|
||||||
} // a);
|
} // a);
|
||||||
|
|
||||||
|
requiredPlugins = {
|
||||||
|
knownPlugins ? vimPlugins,
|
||||||
|
vam ? null,
|
||||||
|
pathogen ? null, ...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
pathogenNames = map (name: knownPlugins.${name}) (findDependenciesRecursively { inherit knownPlugins; names = pathogen.pluginNames; });
|
||||||
|
vamNames = findDependenciesRecursively { inherit knownPlugins; names = lib.concatMap toNames vam.pluginDictionaries; };
|
||||||
|
names = (lib.optionals (pathogen != null) pathogenNames) ++
|
||||||
|
(lib.optionals (vam != null) vamNames);
|
||||||
|
in
|
||||||
|
map (name: knownPlugins.${name}) names;
|
||||||
|
|
||||||
# test cases:
|
# test cases:
|
||||||
test_vim_with_vim_addon_nix_using_vam = vim_configurable.customize {
|
test_vim_with_vim_addon_nix_using_vam = vim_configurable.customize {
|
||||||
name = "vim-with-vim-addon-nix-using-vam";
|
name = "vim-with-vim-addon-nix-using-vam";
|
||||||
@ -427,5 +439,4 @@ rec {
|
|||||||
name = "vim-with-vim-addon-nix";
|
name = "vim-with-vim-addon-nix";
|
||||||
vimrcConfig.packages.myVimPackage.start = with vimPlugins; [ vim-addon-nix ];
|
vimrcConfig.packages.myVimPackage.start = with vimPlugins; [ vim-addon-nix ];
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user