diff --git a/nixos/modules/config/system-path.nix b/nixos/modules/config/system-path.nix index 2ea998bbb63..6b4c38172e9 100644 --- a/nixos/modules/config/system-path.nix +++ b/nixos/modules/config/system-path.nix @@ -110,6 +110,7 @@ in "/man" "/sbin" "/share/emacs" + "/share/vim-plugins" "/share/org" "/share/info" "/share/terminfo" diff --git a/pkgs/applications/editors/vim/configurable.nix b/pkgs/applications/editors/vim/configurable.nix index e0d8de157b0..bf53b4972c1 100644 --- a/pkgs/applications/editors/vim/configurable.nix +++ b/pkgs/applications/editors/vim/configurable.nix @@ -1,9 +1,26 @@ # TODO tidy up eg The patchelf code is patching gvim even if you don't build it.. # but I have gvim with python support now :) - Marc -args@{source ? "default", ...}: with args; +args@{pkgs, source ? "default", ...}: with args; -let inherit (args.composableDerivation) composableDerivation edf; in +let inherit (args.composableDerivation) composableDerivation edf; + nixosRuntimepath = pkgs.writeText "runtimepath.vim" '' + function! NixosPluginPath() + let seen = {} + for p in reverse(split($NIX_PROFILES)) + for d in split(glob(p . '/share/vim-plugins/*')) + let pluginname = substitute(d, ".*/", "", "") + if !has_key(seen, pluginname) + exec 'set runtimepath^='.d + let seen[pluginname] = 1 + endif + endfor + endfor + endfunction + + execute NixosPluginPath() + ''; +in composableDerivation { # use gccApple to compile on darwin mkDerivation = ( if stdenv.isDarwin @@ -145,6 +162,8 @@ composableDerivation { echo $nativeBuildInputs echo $rpath patchelf --set-rpath $rpath $out/bin/{vim,gvim} + + ln -sfn ${nixosRuntimepath} $out/share/vim/vimrc ''; dontStrip = 1; diff --git a/pkgs/misc/vim-plugins/default.nix b/pkgs/misc/vim-plugins/default.nix index 976e4dc687f..54616341a13 100644 --- a/pkgs/misc/vim-plugins/default.nix +++ b/pkgs/misc/vim-plugins/default.nix @@ -88,8 +88,8 @@ let vimHelpTags = '' inherit buildPhase; installPhase = '' - target=$out/vim-plugins/$path - ensureDir $out/vim-plugins + target=$out/share/vim-plugins/${path} + ensureDir $out/share/vim-plugins cp -r . $target ${vimHelpTags} vimHelpTags $target @@ -114,14 +114,14 @@ in rec rev = "abfc3ee36adab11c0c0b9d086a164a69006fec79"; sha256 = "1d25dp5kgqickl06hqvx4j3z51zblhsn3q3by2hayyj3g2zps4gm"; }; - + name = "youcompleteme-git-abfc3ee"; buildInputs = [ python cmake clang.clang ]; configurePhase = ":"; buildPhase = '' - target=$out/vim-plugins/YouCompleteMe + target=$out/share/vim-plugins/YouCompleteMe mkdir -p $target cp -a ./ $target @@ -311,7 +311,7 @@ in rec preBuild = '' sed -ie '1 i\ - set runtimepath+=${vimproc}/vim-plugins/vimproc\ + set runtimepath+=${vimproc}/share/vim-plugins/vimproc\ ' autoload/vimshell.vim '';