diff options
author | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2018-07-22 20:04:49 -0400 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2018-07-23 02:04:49 +0200 |
commit | c9f2faf3bf3402690b6c9070e15a479df09a01da (patch) | |
tree | 6e456954d6ae5f7a4742e84d133b92c76c1c63d2 /src | |
parent | 13d29cb9ed0d6fba734dc5a96ed543326ee14b3f (diff) | |
download | rneovim-c9f2faf3bf3402690b6c9070e15a479df09a01da.tar.gz rneovim-c9f2faf3bf3402690b6c9070e15a479df09a01da.tar.bz2 rneovim-c9f2faf3bf3402690b6c9070e15a479df09a01da.zip |
vim-patch:8.0.1398: :packadd does not load packages from the "start" directory (#8762)
Problem: :packadd does not load packages from the "start" directory.
(Alejandro Hernandez)
Solution: Make :packadd look in the "start" directory if those packages were
not loaded on startup.
https://github.com/vim/vim/commit/9e1d399e63903c6f84d7888ad8d84ebf4e29d8a1
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/ex_cmds2.c | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index f07bc0e137..120278d3fb 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -2693,14 +2693,27 @@ void ex_packloadall(exarg_T *eap) /// ":packadd[!] {name}" void ex_packadd(exarg_T *eap) { - static const char *plugpat = "pack/*/opt/%s"; // NOLINT - - size_t len = STRLEN(plugpat) + STRLEN(eap->arg); - char *pat = (char *)xmallocz(len); - 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 ? &APP_ADD_DIR : &APP_BOTH); - xfree(pat); + static const char *plugpat = "pack/*/%s/%s"; // NOLINT + int res = OK; + + // Round 1: use "start", round 2: use "opt". + for (int round = 1; round <= 2; round++) { + // Only look under "start" when loading packages wasn't done yet. + if (round == 1 && did_source_packages) { + continue; + } + + const size_t len = STRLEN(plugpat) + STRLEN(eap->arg) + 5; + char *pat = xmallocz(len); + vim_snprintf(pat, len, plugpat, round == 1 ? "start" : "opt", eap->arg); + // The first round don't give a "not found" error, in the second round + // only when nothing was found in the first round. + res = do_in_path(p_pp, (char_u *)pat, + DIP_ALL + DIP_DIR + + (round == 2 && res == FAIL ? DIP_ERR : 0), + add_pack_plugin, eap->forceit ? &APP_ADD_DIR : &APP_BOTH); + xfree(pat); + } } /// ":options" |