Problem: ":colorscheme" does not use 'packpath'.
Solution: Also use in "start" and "opt" directories in 'packpath'.
/* try finding "keymap/'keymap'_'encoding'.vim" in 'runtimepath' */
vim_snprintf((char *)buf, buflen, "keymap/%s_%s.vim",
curbuf->b_p_keymap, p_enc);
- if (source_runtime(buf, FALSE) == FAIL)
+ if (source_runtime(buf, 0) == FAIL)
# endif
{
/* try finding "keymap/'keymap'.vim" in 'runtimepath' */
vim_snprintf((char *)buf, buflen, "keymap/%s.vim",
curbuf->b_p_keymap);
- if (source_runtime(buf, FALSE) == FAIL)
+ if (source_runtime(buf, 0) == FAIL)
{
vim_free(buf);
return (char_u *)N_("E544: Keymap file not found");
}
/* Try loading the package from $VIMRUNTIME/autoload/<name>.vim */
- if (source_runtime(scriptname, FALSE) == OK)
+ if (source_runtime(scriptname, 0) == OK)
ret = TRUE;
}
do_unlet((char_u *)"b:current_compiler", TRUE);
sprintf((char *)buf, "compiler/%s.vim", eap->arg);
- if (source_runtime(buf, TRUE) == FAIL)
+ if (source_runtime(buf, DIP_ALL) == FAIL)
EMSG2(_("E666: compiler not supported: %s"), eap->arg);
vim_free(buf);
void
ex_runtime(exarg_T *eap)
{
- source_runtime(eap->arg, eap->forceit);
+ source_runtime(eap->arg, eap->forceit ? DIP_ALL : 0);
}
static void
/*
* Source the file "name" from all directories in 'runtimepath'.
* "name" can contain wildcards.
- * When "all" is TRUE: source all files, otherwise only the first one.
+ * When "flags" has DIP_ALL: 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)
+source_runtime(char_u *name, int flags)
{
- return do_in_runtimepath(name, all, source_callback, NULL);
+ return do_in_runtimepath(name, flags, source_callback, NULL);
}
/*
/*
* Find "name" in 'runtimepath'. When found, invoke the callback function for
* it: callback(fname, "cookie")
- * When "all" is TRUE repeat for all matches, otherwise only the first one is
- * used.
+ * When "flags" has DIP_ALL repeat for all matches, otherwise only the first
+ * one is used.
* Returns OK when at least one match found, FAIL otherwise.
*
* If "name" is NULL calls callback for each entry in runtimepath. Cookie is
int
do_in_runtimepath(
char_u *name,
- int all,
+ int flags,
void (*callback)(char_u *fname, void *ck),
void *cookie)
{
- return do_in_path(p_rtp, name, all ? DIP_ALL : 0, callback, cookie);
+ int done;
+ char_u *s;
+ int len;
+ char *start_dir = "pack/*/start/*/%s";
+ char *opt_dir = "pack/*/opt/*/%s";
+
+ done = do_in_path(p_rtp, name, flags, callback, cookie);
+
+ if (done == FAIL && (flags & DIP_START))
+ {
+ len = STRLEN(start_dir) + STRLEN(name);
+ s = alloc(len);
+ if (s == NULL)
+ return FAIL;
+ vim_snprintf((char *)s, len, start_dir, name);
+ done = do_in_path(p_pp, s, flags, callback, cookie);
+ vim_free(s);
+ }
+
+ if (done == FAIL && (flags & DIP_OPT))
+ {
+ len = STRLEN(opt_dir) + STRLEN(name);
+ s = alloc(len);
+ if (s == NULL)
+ return FAIL;
+ vim_snprintf((char *)s, len, opt_dir, name);
+ done = do_in_path(p_pp, s, flags, callback, cookie);
+ vim_free(s);
+ }
+
+ return done;
}
/*
{
if (*arg == 'o' || !filetype_detect)
{
- source_runtime((char_u *)FILETYPE_FILE, TRUE);
+ source_runtime((char_u *)FILETYPE_FILE, DIP_ALL);
filetype_detect = TRUE;
if (plugin)
{
- source_runtime((char_u *)FTPLUGIN_FILE, TRUE);
+ source_runtime((char_u *)FTPLUGIN_FILE, DIP_ALL);
filetype_plugin = TRUE;
}
if (indent)
{
- source_runtime((char_u *)INDENT_FILE, TRUE);
+ source_runtime((char_u *)INDENT_FILE, DIP_ALL);
filetype_indent = TRUE;
}
}
{
if (plugin)
{
- source_runtime((char_u *)FTPLUGOF_FILE, TRUE);
+ source_runtime((char_u *)FTPLUGOF_FILE, DIP_ALL);
filetype_plugin = FALSE;
}
if (indent)
{
- source_runtime((char_u *)INDOFF_FILE, TRUE);
+ source_runtime((char_u *)INDOFF_FILE, DIP_ALL);
filetype_indent = FALSE;
}
}
else
{
- source_runtime((char_u *)FTOFF_FILE, TRUE);
+ source_runtime((char_u *)FTOFF_FILE, DIP_ALL);
filetype_detect = FALSE;
}
}
if (STRLEN(name) > MAXPATHL - 14)
return FAIL;
vim_snprintf((char *)buffer, MAXPATHL, "bitmaps/%s.%s", name, ext);
- if (do_in_runtimepath(buffer, FALSE, gfp_setname, buffer) == FAIL
+ if (do_in_runtimepath(buffer, 0, gfp_setname, buffer) == FAIL
|| *buffer == NUL)
return FAIL;
return OK;
vim_strcat(buffer, (char_u *)name, MAXPATHL);
vim_strcat(buffer, (char_u *)".ps", MAXPATHL);
resource->filename[0] = NUL;
- retval = (do_in_runtimepath(buffer, FALSE, prt_resource_name,
+ retval = (do_in_runtimepath(buffer, 0, prt_resource_name,
resource->filename)
&& resource->filename[0] != NUL);
vim_free(buffer);
data.callable = callable;
data.result = NULL;
- do_in_runtimepath(NULL, FALSE, &map_rtp_callback, &data);
+ do_in_runtimepath(NULL, 0, &map_rtp_callback, &data);
if (data.result == NULL)
{
if (!(ret = PyList_New(0)))
return NULL;
- do_in_runtimepath(NULL, FALSE, &map_finder_callback, ret);
+ do_in_runtimepath(NULL, 0, &map_finder_callback, ret);
if (PyErr_Occurred())
{
if (p_lpl)
{
# ifdef VMS /* Somehow VMS doesn't handle the "**". */
- source_runtime((char_u *)"plugin/*.vim", TRUE);
+ source_runtime((char_u *)"plugin/*.vim", DIP_ALL);
# else
- source_runtime((char_u *)"plugin/**/*.vim", TRUE);
+ source_runtime((char_u *)"plugin/**/*.vim", DIP_ALL);
# endif
TIME_MSG("loading plugins");
if (vim_strchr((char_u *)"_.,", *p) != NULL)
break;
vim_snprintf((char *)fname, 200, "spell/%.*s.vim", (int)(p - q), q);
- source_runtime(fname, TRUE);
+ source_runtime(fname, DIP_ALL);
}
#endif
}
mch_icon_load(HANDLE *iconp)
{
return do_in_runtimepath((char_u *)"bitmaps/vim.ico",
- FALSE, mch_icon_load_cb, iconp);
+ 0, mch_icon_load_cb, iconp);
}
int
"spell/%s.%s.spl",
#endif
lang, spell_enc());
- r = do_in_runtimepath(fname_enc, FALSE, spell_load_cb, &sl);
+ r = do_in_runtimepath(fname_enc, 0, spell_load_cb, &sl);
if (r == FAIL && *sl.sl_lang != NUL)
{
"spell/%s.ascii.spl",
#endif
lang);
- r = do_in_runtimepath(fname_enc, FALSE, spell_load_cb, &sl);
+ r = do_in_runtimepath(fname_enc, 0, spell_load_cb, &sl);
#ifdef FEAT_AUTOCMD
if (r == FAIL && *sl.sl_lang != NUL && round == 1
{
/* At least one file was loaded, now load ALL the additions. */
STRCPY(fname_enc + STRLEN(fname_enc) - 3, "add.spl");
- do_in_runtimepath(fname_enc, TRUE, spell_load_cb, &sl);
+ do_in_runtimepath(fname_enc, DIP_ALL, spell_load_cb, &sl);
}
}
prev_toplvl_grp = curwin->w_s->b_syn_topgrp;
curwin->w_s->b_syn_topgrp = sgl_id;
if (source ? do_source(eap->arg, FALSE, DOSO_NONE) == FAIL
- : source_runtime(eap->arg, TRUE) == FAIL)
+ : source_runtime(eap->arg, DIP_ALL) == FAIL)
EMSG2(_(e_notopen), eap->arg);
curwin->w_s->b_syn_topgrp = prev_toplvl_grp;
current_syn_inc_tag = prev_syn_inc_tag;
else
{
++recursive;
- (void)source_runtime((char_u *)"syntax/syncolor.vim", TRUE);
+ (void)source_runtime((char_u *)"syntax/syncolor.vim", DIP_ALL);
--recursive;
}
}
if (buf != NULL)
{
sprintf((char *)buf, "colors/%s.vim", name);
- retval = source_runtime(buf, FALSE);
+ retval = source_runtime(buf, DIP_START + DIP_OPT);
vim_free(buf);
#ifdef FEAT_AUTOCMD
apply_autocmds(EVENT_COLORSCHEME, name, curbuf->b_fname, FALSE, curbuf);
#else
"doc/tags"
#endif
- , TRUE, found_tagfile_cb, NULL);
+ , DIP_ALL, found_tagfile_cb, NULL);
}
if (tnp->tn_hf_idx >= tag_fnames.ga_len)
let tags2 = readfile(docdir2 . '/tags')
call assert_true(tags2[0] =~ 'look-away')
endfunc
+
+func Test_colorscheme()
+ let colordirrun = &packpath . '/runtime/colors'
+ let colordirstart = &packpath . '/pack/mine/start/foo/colors'
+ let colordiropt = &packpath . '/pack/mine/opt/bar/colors'
+ call mkdir(colordirrun, 'p')
+ call mkdir(colordirstart, 'p')
+ call mkdir(colordiropt, 'p')
+ call writefile(['let g:found_one = 1'], colordirrun . '/one.vim')
+ call writefile(['let g:found_two = 1'], colordirstart . '/two.vim')
+ call writefile(['let g:found_three = 1'], colordiropt . '/three.vim')
+ exe 'set rtp=' . &packpath . '/runtime'
+
+ colorscheme one
+ call assert_equal(1, g:found_one)
+ colorscheme two
+ call assert_equal(1, g:found_two)
+ colorscheme three
+ call assert_equal(1, g:found_three)
+endfunc
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 1552,
/**/
1551,
/**/
#endif
/* Used for flags of do_in_path() */
-#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. */
+#define DIP_ALL 0x01 /* all matches, not just the first one */
+#define DIP_DIR 0x02 /* find directories instead of files. */
+#define DIP_ERR 0x04 /* give an error message when none found. */
+#define DIP_START 0x08 /* also use "start" directory in 'packpath' */
+#define DIP_OPT 0x10 /* also use "opt" directory in 'packpath' */
#endif /* VIM__H */