Add automatic plugin activation for vim

This commit is contained in:
Paul Colomiets 2014-06-28 23:34:48 +03:00 committed by Bjørn Forsman
parent 0ffcb718a2
commit 496d12958e
3 changed files with 27 additions and 7 deletions

View File

@ -110,6 +110,7 @@ in
"/man" "/man"
"/sbin" "/sbin"
"/share/emacs" "/share/emacs"
"/share/vim-plugins"
"/share/org" "/share/org"
"/share/info" "/share/info"
"/share/terminfo" "/share/terminfo"

View File

@ -1,9 +1,26 @@
# TODO tidy up eg The patchelf code is patching gvim even if you don't build it.. # 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 # 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 { composableDerivation {
# use gccApple to compile on darwin # use gccApple to compile on darwin
mkDerivation = ( if stdenv.isDarwin mkDerivation = ( if stdenv.isDarwin
@ -145,6 +162,8 @@ composableDerivation {
echo $nativeBuildInputs echo $nativeBuildInputs
echo $rpath echo $rpath
patchelf --set-rpath $rpath $out/bin/{vim,gvim} patchelf --set-rpath $rpath $out/bin/{vim,gvim}
ln -sfn ${nixosRuntimepath} $out/share/vim/vimrc
''; '';
dontStrip = 1; dontStrip = 1;

View File

@ -88,8 +88,8 @@ let vimHelpTags = ''
inherit buildPhase; inherit buildPhase;
installPhase = '' installPhase = ''
target=$out/vim-plugins/$path target=$out/share/vim-plugins/${path}
ensureDir $out/vim-plugins ensureDir $out/share/vim-plugins
cp -r . $target cp -r . $target
${vimHelpTags} ${vimHelpTags}
vimHelpTags $target vimHelpTags $target
@ -114,14 +114,14 @@ in rec
rev = "abfc3ee36adab11c0c0b9d086a164a69006fec79"; rev = "abfc3ee36adab11c0c0b9d086a164a69006fec79";
sha256 = "1d25dp5kgqickl06hqvx4j3z51zblhsn3q3by2hayyj3g2zps4gm"; sha256 = "1d25dp5kgqickl06hqvx4j3z51zblhsn3q3by2hayyj3g2zps4gm";
}; };
name = "youcompleteme-git-abfc3ee"; name = "youcompleteme-git-abfc3ee";
buildInputs = [ python cmake clang.clang ]; buildInputs = [ python cmake clang.clang ];
configurePhase = ":"; configurePhase = ":";
buildPhase = '' buildPhase = ''
target=$out/vim-plugins/YouCompleteMe target=$out/share/vim-plugins/YouCompleteMe
mkdir -p $target mkdir -p $target
cp -a ./ $target cp -a ./ $target
@ -311,7 +311,7 @@ in rec
preBuild = '' preBuild = ''
sed -ie '1 i\ sed -ie '1 i\
set runtimepath+=${vimproc}/vim-plugins/vimproc\ set runtimepath+=${vimproc}/share/vim-plugins/vimproc\
' autoload/vimshell.vim ' autoload/vimshell.vim
''; '';