diff options
Diffstat (limited to 'src/nvim/ex_cmds2.c')
-rw-r--r-- | src/nvim/ex_cmds2.c | 28 |
1 files changed, 21 insertions, 7 deletions
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); } |