summaryrefslogtreecommitdiff
path: root/src/ex_cmds2.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2016-04-05 21:13:00 +0200
committerBram Moolenaar <Bram@vim.org>2016-04-05 21:13:00 +0200
commit49b27326447d0827c59c6cd201d58f65c1163086 (patch)
tree0db4d3eb478f28795304810e2194e6cc75efa777 /src/ex_cmds2.c
parenta742e084b677f76c67e9e52c4f9fb9ab24002e20 (diff)
downloadvim-49b27326447d0827c59c6cd201d58f65c1163086.zip
patch 7.4.1712
Problem: For plugins in packages, plugin authors need to take care of all dependencies. Solution: When loading "start" packages and for :packloadall, first add all directories to 'runtimepath' before sourcing plugins.
Diffstat (limited to 'src/ex_cmds2.c')
-rw-r--r--src/ex_cmds2.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c
index 9f74376f1..657c77252 100644
--- a/src/ex_cmds2.c
+++ b/src/ex_cmds2.c
@@ -3313,6 +3313,11 @@ source_all_matches(char_u *pat)
}
}
+/* used for "cookie" of add_pack_plugin() */
+static int APP_ADD_DIR;
+static int APP_LOAD;
+static int APP_BOTH;
+
static void
add_pack_plugin(char_u *fname, void *cookie)
{
@@ -3324,11 +3329,10 @@ add_pack_plugin(char_u *fname, void *cookie)
int oldlen;
int addlen;
char_u *ffname = fix_fname(fname);
- int load_files = cookie != NULL;
if (ffname == NULL)
return;
- if (strstr((char *)p_rtp, (char *)ffname) == NULL)
+ if (cookie != &APP_LOAD && strstr((char *)p_rtp, (char *)ffname) == NULL)
{
/* directory not in 'runtimepath', add it */
p4 = p3 = p2 = p1 = get_past_head(ffname);
@@ -3374,7 +3378,7 @@ add_pack_plugin(char_u *fname, void *cookie)
vim_free(new_rtp);
}
- if (load_files)
+ if (cookie != &APP_ADD_DIR)
{
static char *plugpat = "%s/plugin/**/*.vim";
static char *ftpat = "%s/ftdetect/*.vim";
@@ -3423,8 +3427,14 @@ ex_packloadall(exarg_T *eap)
if (!did_source_packages || (eap != NULL && eap->forceit))
{
did_source_packages = TRUE;
+
+ /* First do a round to add all directories to 'runtimepath', then load
+ * the plugins. This allows for plugins to use an autoload directory
+ * of another plugin. */
+ do_in_path(p_pp, (char_u *)"pack/*/start/*", DIP_ALL + DIP_DIR,
+ add_pack_plugin, &APP_ADD_DIR);
do_in_path(p_pp, (char_u *)"pack/*/start/*", DIP_ALL + DIP_DIR,
- add_pack_plugin, p_pp);
+ add_pack_plugin, &APP_LOAD);
}
}
@@ -3444,7 +3454,7 @@ ex_packadd(exarg_T *eap)
return;
vim_snprintf(pat, len, plugpat, eap->arg);
do_in_path(p_pp, (char_u *)pat, DIP_ALL + DIP_DIR + DIP_ERR,
- add_pack_plugin, eap->forceit ? NULL : p_pp);
+ add_pack_plugin, eap->forceit ? &APP_ADD_DIR : &APP_BOTH);
vim_free(pat);
}