diff options
author | Bram Moolenaar <Bram@vim.org> | 2016-03-12 22:11:39 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2016-03-12 22:11:39 +0100 |
commit | 7f8989dd8a627af2185df381195351a913f3777f (patch) | |
tree | 43e30468ff036d93a02f06a0ab4186f96013adc1 | |
parent | 6bef5306e4f2cacb3a93667992c2312d4b293c9d (diff) | |
download | vim-git-7f8989dd8a627af2185df381195351a913f3777f.tar.gz |
patch 7.4.1552v7.4.1552
Problem: ":colorscheme" does not use 'packpath'.
Solution: Also use in "start" and "opt" directories in 'packpath'.
-rw-r--r-- | src/digraph.c | 4 | ||||
-rw-r--r-- | src/eval.c | 2 | ||||
-rw-r--r-- | src/ex_cmds2.c | 48 | ||||
-rw-r--r-- | src/ex_docmd.c | 12 | ||||
-rw-r--r-- | src/gui.c | 2 | ||||
-rw-r--r-- | src/hardcopy.c | 2 | ||||
-rw-r--r-- | src/if_py_both.h | 4 | ||||
-rw-r--r-- | src/main.c | 4 | ||||
-rw-r--r-- | src/option.c | 2 | ||||
-rw-r--r-- | src/os_mswin.c | 2 | ||||
-rw-r--r-- | src/spell.c | 6 | ||||
-rw-r--r-- | src/syntax.c | 6 | ||||
-rw-r--r-- | src/tag.c | 2 | ||||
-rw-r--r-- | src/testdir/test_packadd.vim | 20 | ||||
-rw-r--r-- | src/version.c | 2 | ||||
-rw-r--r-- | src/vim.h | 8 |
16 files changed, 90 insertions, 36 deletions
diff --git a/src/digraph.c b/src/digraph.c index 5dab51b20..b17340cb2 100644 --- a/src/digraph.c +++ b/src/digraph.c @@ -2320,13 +2320,13 @@ keymap_init(void) /* 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"); diff --git a/src/eval.c b/src/eval.c index 765d9b99d..0b589fdc0 100644 --- a/src/eval.c +++ b/src/eval.c @@ -23942,7 +23942,7 @@ script_autoload( } /* Try loading the package from $VIMRUNTIME/autoload/<name>.vim */ - if (source_runtime(scriptname, FALSE) == OK) + if (source_runtime(scriptname, 0) == OK) ret = TRUE; } diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c index 75146749b..b99d0020e 100644 --- a/src/ex_cmds2.c +++ b/src/ex_cmds2.c @@ -2872,7 +2872,7 @@ ex_compiler(exarg_T *eap) 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); @@ -2906,7 +2906,7 @@ ex_compiler(exarg_T *eap) void ex_runtime(exarg_T *eap) { - source_runtime(eap->arg, eap->forceit); + source_runtime(eap->arg, eap->forceit ? DIP_ALL : 0); } static void @@ -2918,14 +2918,14 @@ source_callback(char_u *fname, void *cookie UNUSED) /* * 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); } /* @@ -3052,8 +3052,8 @@ do_in_path( /* * 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 @@ -3063,11 +3063,41 @@ do_in_path( 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; } /* diff --git a/src/ex_docmd.c b/src/ex_docmd.c index 63e982eee..9b116e2bd 100644 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -11777,16 +11777,16 @@ ex_filetype(exarg_T *eap) { 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; } } @@ -11802,18 +11802,18 @@ ex_filetype(exarg_T *eap) { 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; } } @@ -4988,7 +4988,7 @@ gui_find_bitmap(char_u *name, char_u *buffer, char *ext) 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; diff --git a/src/hardcopy.c b/src/hardcopy.c index b6fa95beb..74fee2e21 100644 --- a/src/hardcopy.c +++ b/src/hardcopy.c @@ -1741,7 +1741,7 @@ prt_find_resource(char *name, struct prt_ps_resource_S *resource) 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); diff --git a/src/if_py_both.h b/src/if_py_both.h index 6ae3fe7f6..e916e6aa8 100644 --- a/src/if_py_both.h +++ b/src/if_py_both.h @@ -1061,7 +1061,7 @@ VimForeachRTP(PyObject *self UNUSED, PyObject *callable) 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) { @@ -1150,7 +1150,7 @@ Vim_GetPaths(PyObject *self UNUSED) 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()) { diff --git a/src/main.c b/src/main.c index 7bbf248e4..8c7d3d68b 100644 --- a/src/main.c +++ b/src/main.c @@ -628,9 +628,9 @@ vim_main2(int argc UNUSED, char **argv UNUSED) 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"); diff --git a/src/option.c b/src/option.c index b624aad09..648919dc7 100644 --- a/src/option.c +++ b/src/option.c @@ -7290,7 +7290,7 @@ did_set_string_option( 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 } diff --git a/src/os_mswin.c b/src/os_mswin.c index 2a80381a0..607fd6a51 100644 --- a/src/os_mswin.c +++ b/src/os_mswin.c @@ -950,7 +950,7 @@ mch_icon_load_cb(char_u *fname, void *cookie) 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 diff --git a/src/spell.c b/src/spell.c index 9220bc0be..3f23bf992 100644 --- a/src/spell.c +++ b/src/spell.c @@ -2478,7 +2478,7 @@ spell_load_lang(char_u *lang) "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) { @@ -2490,7 +2490,7 @@ spell_load_lang(char_u *lang) "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 @@ -2519,7 +2519,7 @@ spell_load_lang(char_u *lang) { /* 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); } } diff --git a/src/syntax.c b/src/syntax.c index ac80ab4e7..7d2233a98 100644 --- a/src/syntax.c +++ b/src/syntax.c @@ -4813,7 +4813,7 @@ syn_cmd_include(exarg_T *eap, int syncing UNUSED) 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; @@ -7075,7 +7075,7 @@ init_highlight( else { ++recursive; - (void)source_runtime((char_u *)"syntax/syncolor.vim", TRUE); + (void)source_runtime((char_u *)"syntax/syncolor.vim", DIP_ALL); --recursive; } } @@ -7104,7 +7104,7 @@ load_colors(char_u *name) 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); @@ -2638,7 +2638,7 @@ get_tagfname( #else "doc/tags" #endif - , TRUE, found_tagfile_cb, NULL); + , DIP_ALL, found_tagfile_cb, NULL); } if (tnp->tn_hf_idx >= tag_fnames.ga_len) diff --git a/src/testdir/test_packadd.vim b/src/testdir/test_packadd.vim index 008bb9370..3ca8375fc 100644 --- a/src/testdir/test_packadd.vim +++ b/src/testdir/test_packadd.vim @@ -114,3 +114,23 @@ func Test_helptags() 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 diff --git a/src/version.c b/src/version.c index 5d142703a..d77d4805b 100644 --- a/src/version.c +++ b/src/version.c @@ -744,6 +744,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1552, +/**/ 1551, /**/ 1550, @@ -2289,8 +2289,10 @@ int vim_main2(int argc, char **argv); #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 */ |