git.iko.soy/typeable/nixpkgs
on master help sign in
vimUtils: add dependency logic to nativeImpl

nativeImpl previously simply ignored dependency information.

commit8e8a09bfc9546edca6623f713bd1be2cb544da21 authorTimo Kaufmann <timokau@zoho.com> dateMon 24 Dec 2018, 13:13 (8 years ago) parentb352318
2 files changed+17−2
doc/languages-frameworks/vim.section.md+6−1 pkgs/misc/vim-plugins/vim-utils.nix+11−1
doc/languages-frameworks/vim.section.md+6−1
@@ -48,7 +48,7 @@ neovim.override {
4848
4949## Managing plugins with Vim packages
5050
51−To store you plugins in Vim packages the following example can be used:
51+To store you plugins in Vim packages (the native vim plugin manager, see `:help packages`) the following example can be used:
5252
5353```
5454vim_configurable.customize {
@@ -56,6 +56,8 @@ vim_configurable.customize {
5656 # loaded on launch
5757 start = [ youcompleteme fugitive ];
5858 # manually loadable by calling `:packadd $plugin-name`
59+ # however, if a vim plugin has a dependency that is not explicitly listed in
60+ # opt that dependency will always be added to start to avoid confusion.
5961 opt = [ phpCompletion elm-vim ];
6062 # To automatically load a plugin when opening a filetype, add vimrc lines like:
6163 # autocmd FileType php :packadd phpCompletion
@@ -63,6 +65,7 @@ vim_configurable.customize {
6365}
6466```
6567
68+`myVimPackage` is an arbitrary name for the generated package. You can choose any name you like.
6669For Neovim the syntax is:
6770
6871```
@@ -74,6 +77,8 @@ neovim.override {
7477 packages.myVimPackage = with pkgs.vimPlugins; {
7578 # see examples below how to use custom packages
7679 start = [ ];
80+ # If a vim plugin has a dependency that is not explicitly listed in
81+ # opt that dependency will always be added to start to avoid confusion.
7782 opt = [ ];
7883 };
7984 };
pkgs/misc/vim-plugins/vim-utils.nix+11−1
@@ -293,8 +293,18 @@ let
293293 (let
294294 link = (packageName: dir: pluginPath: "ln -sf ${pluginPath}/share/vim-plugins/* $out/pack/${packageName}/${dir}");
295295 packageLinks = (packageName: {start ? [], opt ? []}:
296+ let
297+ # `nativeImpl` expects packages to be derivations, not strings (as
298+ # opposed to older implementations that have to maintain backwards
299+ # compatibility). Therefore we don't need to deal with "knownPlugins"
300+ # and can simply pass `null`.
301+ depsOfOptionalPlugins = lib.subtractLists opt (findDependenciesRecursively null opt);
302+ startWithDeps = findDependenciesRecursively null start;
303+ in
296304 ["mkdir -p $out/pack/${packageName}/start"]
297− ++ (builtins.map (link packageName "start") start)
305+ # To avoid confusion, even dependencies of optional plugins are added
306+ # to `start` (except if they are explicitly listed as optional plugins).
307+ ++ (builtins.map (link packageName "start") (lib.unique (startWithDeps ++ depsOfOptionalPlugins)))
298308 ++ ["mkdir -p $out/pack/${packageName}/opt"]
299309 ++ (builtins.map (link packageName "opt") opt)
300310 );