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.
wip/yesman
Evan Danaher 7 years ago
parent 6018cf4a69
commit dcab427908
  1. 10
      pkgs/applications/editors/neovim/default.nix
  2. 1
      pkgs/misc/vim-plugins/default.nix
  3. 23
      pkgs/misc/vim-plugins/vim-utils.nix

@ -53,18 +53,24 @@ let
rubyWrapper = ''--suffix PATH : \"${rubyEnv}/bin\" '' +
''--suffix GEM_HOME : \"${rubyEnv}/${rubyEnv.ruby.gemPath}\" '';
pluginPythonPackages = builtins.concatLists
(map ({ pythonDependencies ? [], ...}: pythonDependencies)
(vimUtils.requiredPlugins configure));
pythonEnv = pythonPackages.python.buildEnv.override {
extraLibs = (
if withPyGUI
then [ pythonPackages.neovim_gui ]
else [ pythonPackages.neovim ]
) ++ extraPythonPackages;
) ++ extraPythonPackages ++ pluginPythonPackages;
ignoreCollisions = true;
};
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 {
extraLibs = [ python3Packages.neovim ] ++ extraPython3Packages;
extraLibs = [ python3Packages.neovim ] ++ extraPython3Packages ++ pluginPython3Packages;
ignoreCollisions = true;
};
python3Wrapper = ''--cmd \"let g:python3_host_prog='$out/bin/nvim-python3'\" '';

@ -4,6 +4,7 @@
, xkb_switch, rustracerd, fzf
, python3, boost, icu
, ycmd
, pythonPackages, python3Packages
, Cocoa ? null
}:

@ -150,6 +150,10 @@ vim_with_plugins can be installed like any other application within Nix.
let
inherit (stdenv) lib;
toNames = x:
if builtins.isString x then [x]
else (lib.optional (x ? name) x.name)
++ (x.names or []);
findDependenciesRecursively = {knownPlugins, names}:
let depsOf = name: (builtins.getAttr name knownPlugins).dependencies or [];
@ -211,11 +215,6 @@ let
(let
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; };
# Vim almost reads JSON, so eventually JSON support should be added to Nix
@ -412,6 +411,19 @@ rec {
configurePhase =":";
} // 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_vim_with_vim_addon_nix_using_vam = vim_configurable.customize {
name = "vim-with-vim-addon-nix-using-vam";
@ -427,5 +439,4 @@ rec {
name = "vim-with-vim-addon-nix";
vimrcConfig.packages.myVimPackage.start = with vimPlugins; [ vim-addon-nix ];
};
}

Loading…
Cancel
Save