mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-24 16:03:23 +00:00
vim_configurable: Add packPath option to vimrcConfig (#22776)
* vim_configurable: Add packages option to vimrcConfig Version 8 of vim adds the concept of "vim packages": directories which contain one or more vim plugins, in either "start" or "opt" subdirectories. Those in "start" are to be loaded automatically, while those in "opt" can be loaded manually. Vim detects any packages located in one of its "packpaths". The packages option takes a set of sets describing one or more vim packages, and adds the derivation containing these packages to the packpath. * fix documentation.
This commit is contained in:
parent
4ecaed783b
commit
7bb0611e2e
@ -17,6 +17,17 @@ vim-with-plugins in PATH:
|
||||
set hidden
|
||||
'';
|
||||
|
||||
# store your plugins in Vim packages
|
||||
vimrcConfig.packages.myVimPackage = with pkgs.vimPlugins; {
|
||||
# loaded on launch
|
||||
start = [ youcompleteme fugitive ];
|
||||
# manually loadable by calling `:packadd $plugin-name`
|
||||
opt = [ phpCompletion elm-vim ];
|
||||
# To automatically load a plugin when opening a filetype, add vimrc lines like:
|
||||
# autocmd FileType php :packadd phpCompletion
|
||||
};
|
||||
|
||||
# plugins can also be managed by VAM
|
||||
vimrcConfig.vam.knownPlugins = pkgs.vimPlugins; # optional
|
||||
vimrcConfig.vam.pluginDictionaries = [
|
||||
# load always
|
||||
@ -154,6 +165,7 @@ let
|
||||
in lib.uniqList { inputList = recurseNames [] names; };
|
||||
|
||||
vimrcFile = {
|
||||
packages ? null,
|
||||
vam ? null,
|
||||
pathogen ? null,
|
||||
customRC ? ""
|
||||
@ -253,6 +265,31 @@ let
|
||||
call vam#Scripts(l, {})
|
||||
'');
|
||||
|
||||
nativeImpl = lib.optionalString (packages != null)
|
||||
(let
|
||||
link = (packageName: dir: pluginPath: "ln -sf ${pluginPath}/share/vim-plugins/* $out/pack/${packageName}/${dir}");
|
||||
packageLinks = (packageName: {start ? [], opt ? []}:
|
||||
["mkdir -p $out/pack/${packageName}/start"]
|
||||
++ (builtins.map (link packageName "start") start)
|
||||
++ ["mkdir -p $out/pack/${packageName}/opt"]
|
||||
++ (builtins.map (link packageName "opt") opt)
|
||||
);
|
||||
packDir = (packages:
|
||||
stdenv.mkDerivation rec {
|
||||
name = "vim-pack-dir";
|
||||
src = ./.;
|
||||
installPhase = lib.concatStringsSep
|
||||
"\n"
|
||||
(lib.flatten (lib.mapAttrsToList packageLinks packages));
|
||||
}
|
||||
);
|
||||
in
|
||||
''
|
||||
set packpath-=~/.vim/after
|
||||
set packpath+=${packDir packages}
|
||||
set packpath+=~/.vim/after
|
||||
'');
|
||||
|
||||
# somebody else could provide these implementations
|
||||
vundleImpl = "";
|
||||
|
||||
@ -267,6 +304,7 @@ let
|
||||
${pathogenImpl}
|
||||
${vundleImpl}
|
||||
${neobundleImpl}
|
||||
${nativeImpl}
|
||||
|
||||
filetype indent plugin on | syn on
|
||||
|
||||
@ -385,4 +423,9 @@ rec {
|
||||
vimrcConfig.pathogen.pluginNames = [ "vim-addon-nix" ];
|
||||
};
|
||||
|
||||
test_vim_with_vim_addon_nix = vim_configurable.customize {
|
||||
name = "vim-with-vim-addon-nix";
|
||||
vimrcConfig.packages.myVimPackage.start = with vimPlugins; [ vim-addon-nix ];
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user