From dcab4279083a4c04c5d64d40eda3a98e903085b9 Mon Sep 17 00:00:00 2001 From: Evan Danaher Date: Mon, 27 Feb 2017 12:27:45 -0500 Subject: [PATCH 1/2] 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. --- pkgs/applications/editors/neovim/default.nix | 10 +++++++-- pkgs/misc/vim-plugins/default.nix | 1 + pkgs/misc/vim-plugins/vim-utils.nix | 23 +++++++++++++++----- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/pkgs/applications/editors/neovim/default.nix b/pkgs/applications/editors/neovim/default.nix index cbaf14cee603..6d5a37509fc5 100644 --- a/pkgs/applications/editors/neovim/default.nix +++ b/pkgs/applications/editors/neovim/default.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'\" ''; diff --git a/pkgs/misc/vim-plugins/default.nix b/pkgs/misc/vim-plugins/default.nix index c8872a40e561..01ed0d4d5f07 100644 --- a/pkgs/misc/vim-plugins/default.nix +++ b/pkgs/misc/vim-plugins/default.nix @@ -4,6 +4,7 @@ , xkb_switch, rustracerd, fzf , python3, boost, icu , ycmd +, pythonPackages, python3Packages , Cocoa ? null }: diff --git a/pkgs/misc/vim-plugins/vim-utils.nix b/pkgs/misc/vim-plugins/vim-utils.nix index 4b754f15c0fa..6fad58269c0d 100644 --- a/pkgs/misc/vim-plugins/vim-utils.nix +++ b/pkgs/misc/vim-plugins/vim-utils.nix @@ -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 ]; }; - } From 4b9ec73288288a693576795494705f42a626fadd Mon Sep 17 00:00:00 2001 From: Evan Danaher Date: Mon, 27 Feb 2017 12:28:42 -0500 Subject: [PATCH 2/2] vim-plugins: Add ensime-vim and dependencies. --- pkgs/misc/vim-plugins/default.nix | 34 ++++++++++++++++++++++++++ pkgs/misc/vim-plugins/vim-plugin-names | 1 + 2 files changed, 35 insertions(+) diff --git a/pkgs/misc/vim-plugins/default.nix b/pkgs/misc/vim-plugins/default.nix index 01ed0d4d5f07..e6946d348e5e 100644 --- a/pkgs/misc/vim-plugins/default.nix +++ b/pkgs/misc/vim-plugins/default.nix @@ -345,6 +345,18 @@ rec { }; + ensime-vim = buildVimPluginFrom2Nix { # created by nix#NixDerivation + name = "ensime-vim-2017-02-06"; + src = fetchgit { + url = "git://github.com/ensime/ensime-vim"; + rev = "7b5f79c67a078c6e1e5f8c906d4227ce86d33df8"; + sha256 = "04knizaa4gc1z22gxj41qybjl4ysqpv15rwi28h10l7gk9fb1b41"; + }; + dependencies = ["vimproc" "vimshell" "self" "forms"]; + + pythonDependencies = with pythonPackages; [ sexpdata websocket_client ]; + }; + extradite = buildVimPluginFrom2Nix { # created by nix#NixDerivation name = "extradite-2015-09-22"; src = fetchgit { @@ -356,6 +368,17 @@ rec { }; + forms = buildVimPluginFrom2Nix { # created by nix#NixDerivation + name = "forms-2012-11-28"; + src = fetchgit { + url = "git://github.com/megaannum/forms"; + rev = "b601e03fe0a3b8a43766231f4a6217e4492b4f75"; + sha256 = "19kp1i5c6jmnpbsap9giayqbzlv7vh02mp4mjvicqj9n0nfyay74"; + }; + dependencies = ["self"]; + + }; + fugitive = buildVimPluginFrom2Nix { # created by nix#NixDerivation name = "fugitive-2017-02-10"; src = fetchgit { @@ -1166,6 +1189,17 @@ rec { ''; }; + self = buildVimPluginFrom2Nix { # created by nix#NixDerivation + name = "self-2014-05-28"; + src = fetchgit { + url = "git://github.com/megaannum/self"; + rev = "2ed666b547eddee6ae1fcc63babca4ba0b66a59f"; + sha256 = "1gcwn6i5i3msg7hrlzsnv1bs6pm4jz9cff8ppaz2xdj8xv9qy6fn"; + }; + dependencies = []; + + }; + shabadou-vim = buildVimPluginFrom2Nix { # created by nix#NixDerivation name = "shabadou-vim-2016-07-19"; src = fetchgit { diff --git a/pkgs/misc/vim-plugins/vim-plugin-names b/pkgs/misc/vim-plugins/vim-plugin-names index b12983b4bc09..8840114fee11 100644 --- a/pkgs/misc/vim-plugins/vim-plugin-names +++ b/pkgs/misc/vim-plugins/vim-plugin-names @@ -46,6 +46,7 @@ "github:elmcast/elm-vim" "github:embear/vim-localvimrc" "github:enomsg/vim-haskellConcealPlus" +"github:ensime/ensime-vim" "github:esneider/YUNOcommit.vim" "github:fatih/vim-go" "github:flazz/vim-colorschemes"