patch 8.0.0612: pack dirs are added to 'runtimepath' too late
Problem: Package directories are added to 'runtimepath' only after loading
non-package plugins.
Solution: Split off the code to add package directories to 'runtimepath'.
(Ingo Karkat, closes #1680)
diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c
index 36ee57e..225225a 100644
--- a/src/ex_cmds2.c
+++ b/src/ex_cmds2.c
@@ -3633,27 +3633,41 @@
vim_free(ffname);
}
-static int did_source_packages = FALSE;
+/*
+ * Add all packages in the "start" directory to 'runtimepath'.
+ */
+ void
+add_pack_start_dirs(void)
+{
+ do_in_path(p_pp, (char_u *)"pack/*/start/*", DIP_ALL + DIP_DIR,
+ add_pack_plugin, &APP_ADD_DIR);
+}
+
+/*
+ * Load plugins from all packages in the "start" directory.
+ */
+ void
+load_start_packages(void)
+{
+ did_source_packages = TRUE;
+ do_in_path(p_pp, (char_u *)"pack/*/start/*", DIP_ALL + DIP_DIR,
+ add_pack_plugin, &APP_LOAD);
+}
/*
* ":packloadall"
* Find plugins in the package directories and source them.
- * "eap" is NULL when invoked during startup.
*/
void
ex_packloadall(exarg_T *eap)
{
- if (!did_source_packages || (eap != NULL && eap->forceit))
+ if (!did_source_packages || 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, &APP_LOAD);
+ add_pack_start_dirs();
+ load_start_packages();
}
}