diff options
-rw-r--r-- | runtime/doc/repeat.txt | 2 | ||||
-rw-r--r-- | src/nvim/ex_cmds.lua | 2 | ||||
-rw-r--r-- | src/nvim/ex_cmds2.c | 28 | ||||
-rw-r--r-- | src/nvim/globals.h | 1 | ||||
-rw-r--r-- | src/nvim/version.c | 2 | ||||
-rw-r--r-- | test/functional/legacy/packadd_spec.lua | 4 |
6 files changed, 29 insertions, 10 deletions
diff --git a/runtime/doc/repeat.txt b/runtime/doc/repeat.txt index a7873ce002..122e995f0a 100644 --- a/runtime/doc/repeat.txt +++ b/runtime/doc/repeat.txt @@ -204,7 +204,7 @@ For writing a Vim script, see chapter 41 of the user manual |usr_41.txt|. When 'verbose' is two or higher, there is a message about each searched file. - *:pa* *:packadd* + *:pa* *:packadd* *E919* :pa[ckadd][!] {name} Search for an optional plugin directory in 'packpath' and source any plugin files found. The directory must match: diff --git a/src/nvim/ex_cmds.lua b/src/nvim/ex_cmds.lua index 81a0610a90..0e8cf21d69 100644 --- a/src/nvim/ex_cmds.lua +++ b/src/nvim/ex_cmds.lua @@ -1850,7 +1850,7 @@ return { }, { command='packadd', - flags=bit.bor(BANG, FILE1, TRLBAR, SBOXOK, CMDWIN), + flags=bit.bor(BANG, FILE1, NEEDARG, TRLBAR, SBOXOK, CMDWIN), addr_type=ADDR_LINES, func='ex_packadd', }, diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index 6bfa494094..8e88a55d41 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -2277,8 +2277,7 @@ static void source_callback(char_u *fname, void *cookie) /// Source the file "name" from all directories in 'runtimepath'. /// "name" can contain wildcards. -/// When "flags" has DIP_ALL: source all files, otherwise only the first one. -/// When "flags" has DIP_DIR: find directories instead of files. +/// When "all" is true: source all files, otherwise only the first one. /// /// return FAIL when no file could be sourced, OK otherwise. int source_runtime(char_u *name, int all) @@ -2288,7 +2287,16 @@ int source_runtime(char_u *name, int all) #define DIP_ALL 1 // all matches, not just the first one #define DIP_DIR 2 // find directories instead of files. +#define DIP_ERR 4 // give an error message when none found. +/// Find the file "name" in all directories in "path" and invoke +/// "callback(fname, cookie)". +/// "name" can contain wildcards. +/// When "flags" has DIP_ALL: source all files, otherwise only the first one. +/// When "flags" has DIP_DIR: find directories instead of files. +/// When "flags" has DIP_ERR: give an error message if there is no match. +/// +/// return FAIL when no file could be sourced, OK otherwise. static int do_in_path(char_u *path, char_u *name, int flags, DoInRuntimepathCB callback, void *cookie) { @@ -2357,10 +2365,16 @@ static int do_in_path(char_u *path, char_u *name, int flags, } xfree(buf); xfree(rtp_copy); - if (p_verbose > 0 && !did_one && name != NULL) { - verbose_enter(); - smsg(_("not found in 'runtimepath': \"%s\""), name); - verbose_leave(); + if (!did_one && name != NULL) { + char *basepath = path == p_rtp ? "runtimepath" : "packpath"; + + if (flags & DIP_ERR) { + EMSG3(_(e_dirnotf), basepath, name); + } else if (p_verbose > 0) { + verbose_enter(); + smsg(_("not found in '%s': \"%s\""), basepath, name); + verbose_leave(); + } } @@ -2497,7 +2511,7 @@ void ex_packadd(exarg_T *eap) 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, add_pack_plugin, + do_in_path(p_pp, (char_u *)pat, DIP_ALL + DIP_DIR + DIP_ERR, add_pack_plugin, eap->forceit ? NULL : p_pp); xfree(pat); } diff --git a/src/nvim/globals.h b/src/nvim/globals.h index 7f91903106..bfe2ec7fc7 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -1223,6 +1223,7 @@ EXTERN char_u e_invalpat[] INIT(= N_( EXTERN char_u e_bufloaded[] INIT(= N_("E139: File is loaded in another buffer")); EXTERN char_u e_notset[] INIT(= N_("E764: Option '%s' is not set")); EXTERN char_u e_invalidreg[] INIT(= N_("E850: Invalid register name")); +EXTERN char_u e_dirnotf[] INIT(= N_("E919: Directory not found in '%s': \"%s\"")); EXTERN char_u e_unsupportedoption[] INIT(= N_("E519: Option not supported")); diff --git a/src/nvim/version.c b/src/nvim/version.c index 36f9fecf64..6f5ebb751d 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -196,7 +196,7 @@ static int included_patches[] = { // 1502 NA // 1501 NA 1500, - // 1499, + 1499, // 1498 NA // 1497 NA // 1496 NA diff --git a/test/functional/legacy/packadd_spec.lua b/test/functional/legacy/packadd_spec.lua index 9ca7c4e723..e84a8e60d6 100644 --- a/test/functional/legacy/packadd_spec.lua +++ b/test/functional/legacy/packadd_spec.lua @@ -45,6 +45,10 @@ describe('packadd', function() call assert_true(17, g:ftdetect_works) call assert_true(len(&rtp) > len(rtp)) call assert_true(&rtp =~ (s:plugdir . '\($\|,\)')) + + " Check exception + call assert_fails("packadd directorynotfound", 'E919:') + call assert_fails("packadd", 'E471:') endfunc func Test_packadd_noload() |