diff options
author | James McCoy <jamessan@jamessan.com> | 2016-06-20 20:34:24 -0400 |
---|---|---|
committer | James McCoy <jamessan@jamessan.com> | 2016-07-08 01:45:15 -0400 |
commit | 080476882be32768a97e26af22133435ccb8fc2a (patch) | |
tree | dfbde66af3230fb1ed70319ea0c92930eda94806 /src | |
parent | 55dcf0918c364dd58e700cde5f2efbf7da4b3051 (diff) | |
download | rneovim-080476882be32768a97e26af22133435ccb8fc2a.tar.gz rneovim-080476882be32768a97e26af22133435ccb8fc2a.tar.bz2 rneovim-080476882be32768a97e26af22133435ccb8fc2a.zip |
vim-patch:7.4.1552
Problem: ":colorscheme" does not use 'packpath'.
Solution: Also use in "start" and "opt" directories in 'packpath'.
https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/digraph.c | 4 | ||||
-rw-r--r-- | src/nvim/eval.c | 2 | ||||
-rw-r--r-- | src/nvim/ex_cmds2.c | 42 | ||||
-rw-r--r-- | src/nvim/ex_docmd.c | 12 | ||||
-rw-r--r-- | src/nvim/hardcopy.c | 3 | ||||
-rw-r--r-- | src/nvim/main.c | 2 | ||||
-rw-r--r-- | src/nvim/option.c | 2 | ||||
-rw-r--r-- | src/nvim/spell.c | 6 | ||||
-rw-r--r-- | src/nvim/syntax.c | 6 | ||||
-rw-r--r-- | src/nvim/tag.c | 5 | ||||
-rw-r--r-- | src/nvim/version.c | 2 | ||||
-rw-r--r-- | src/nvim/vim.h | 10 |
12 files changed, 60 insertions, 36 deletions
diff --git a/src/nvim/digraph.c b/src/nvim/digraph.c index 9525024c1b..aad145b3e5 100644 --- a/src/nvim/digraph.c +++ b/src/nvim/digraph.c @@ -1757,12 +1757,12 @@ char_u* keymap_init(void) vim_snprintf(buf, buflen, "keymap/%s_%s.vim", curbuf->b_p_keymap, p_enc); - if (source_runtime((char_u *)buf, FALSE) == FAIL) { + if (source_runtime((char_u *)buf, 0) == FAIL) { // try finding "keymap/'keymap'.vim" in 'runtimepath' vim_snprintf(buf, buflen, "keymap/%s.vim", curbuf->b_p_keymap); - if (source_runtime((char_u *)buf, FALSE) == FAIL) { + if (source_runtime((char_u *)buf, 0) == FAIL) { xfree(buf); return (char_u *)N_("E544: Keymap file not found"); } diff --git a/src/nvim/eval.c b/src/nvim/eval.c index d2b9bf66e1..89b1702be2 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -20499,7 +20499,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/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index dda8bf782e..8d298ee0a3 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -2237,7 +2237,7 @@ void ex_compiler(exarg_T *eap) do_unlet((char_u *)"b:current_compiler", true); snprintf((char *)buf, bufsize, "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); } xfree(buf); @@ -2266,7 +2266,7 @@ void ex_compiler(exarg_T *eap) /// ":runtime {name}" void ex_runtime(exarg_T *eap) { - source_runtime(eap->arg, eap->forceit); + source_runtime(eap->arg, eap->forceit ? DIP_ALL : 0); } @@ -2277,12 +2277,12 @@ static void source_callback(char_u *fname, void *cookie) /// 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) +int 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 the file "name" in all directories in "path" and invoke @@ -2379,16 +2379,40 @@ int do_in_path(char_u *path, char_u *name, int flags, /// 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 /// passed by reference in this case, setting it to NULL indicates that callback /// has done its job. -int do_in_runtimepath(char_u *name, bool all, DoInRuntimepathCB callback, +int do_in_runtimepath(char_u *name, int flags, DoInRuntimepathCB callback, void *cookie) { - return do_in_path(p_rtp, name, all ? DIP_ALL : 0, callback, cookie); + int done = do_in_path(p_rtp, name, flags, callback, cookie); + + if (done == FAIL && (flags & DIP_START)) { + char *start_dir = "pack/*/start/*/%s"; + size_t len = STRLEN(start_dir) + STRLEN(name); + char_u *s = xmallocz(len); + + vim_snprintf((char *)s, len, start_dir, name); + done = do_in_path(p_pp, s, flags, callback, cookie); + + xfree(s); + } + + if (done == FAIL && (flags & DIP_OPT)) { + char *opt_dir = "pack/*/opt/*/%s"; + size_t len = STRLEN(opt_dir) + STRLEN(name); + char_u *s = xmallocz(len); + + vim_snprintf((char *)s, len, opt_dir, name); + done = do_in_path(p_pp, s, flags, callback, cookie); + + xfree(s); + } + + return done; } // Expand wildcards in "pat" and invoke do_source() for each match. diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 80dad3605a..31d2da9bb9 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -9336,14 +9336,14 @@ static void ex_filetype(exarg_T *eap) } if (STRCMP(arg, "on") == 0 || STRCMP(arg, "detect") == 0) { if (*arg == 'o' || !filetype_detect) { - source_runtime((char_u *)FILETYPE_FILE, true); + source_runtime((char_u *)FILETYPE_FILE, DIP_ALL); filetype_detect = kTrue; if (plugin) { - source_runtime((char_u *)FTPLUGIN_FILE, true); + source_runtime((char_u *)FTPLUGIN_FILE, DIP_ALL); filetype_plugin = kTrue; } if (indent) { - source_runtime((char_u *)INDENT_FILE, true); + source_runtime((char_u *)INDENT_FILE, DIP_ALL); filetype_indent = kTrue; } } @@ -9354,15 +9354,15 @@ static void ex_filetype(exarg_T *eap) } else if (STRCMP(arg, "off") == 0) { if (plugin || indent) { if (plugin) { - source_runtime((char_u *)FTPLUGOF_FILE, true); + source_runtime((char_u *)FTPLUGOF_FILE, DIP_ALL); filetype_plugin = kFalse; } if (indent) { - source_runtime((char_u *)INDOFF_FILE, true); + source_runtime((char_u *)INDOFF_FILE, DIP_ALL); filetype_indent = kFalse; } } else { - source_runtime((char_u *)FTOFF_FILE, true); + source_runtime((char_u *)FTOFF_FILE, DIP_ALL); filetype_detect = kFalse; } } else diff --git a/src/nvim/hardcopy.c b/src/nvim/hardcopy.c index 916d27a964..1c9b8e18ef 100644 --- a/src/nvim/hardcopy.c +++ b/src/nvim/hardcopy.c @@ -1526,8 +1526,7 @@ static int 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, - resource->filename) + retval = (do_in_runtimepath(buffer, 0, prt_resource_name, resource->filename) && resource->filename[0] != NUL); xfree(buffer); return retval; diff --git a/src/nvim/main.c b/src/nvim/main.c index 787a99802b..c7eafb4741 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -1241,7 +1241,7 @@ static void set_window_layout(mparm_T *paramp) static void load_plugins(void) { if (p_lpl) { - source_runtime((char_u *)"plugin/**/*.vim", TRUE); + source_runtime((char_u *)"plugin/**/*.vim", DIP_ALL); TIME_MSG("loading plugins"); ex_packloadall(NULL); diff --git a/src/nvim/option.c b/src/nvim/option.c index be3cb914b2..fad46ddf2d 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -3188,7 +3188,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); } } diff --git a/src/nvim/spell.c b/src/nvim/spell.c index fba6fac821..d688b3e7f4 100644 --- a/src/nvim/spell.c +++ b/src/nvim/spell.c @@ -2319,14 +2319,14 @@ static void spell_load_lang(char_u *lang) vim_snprintf((char *)fname_enc, sizeof(fname_enc) - 5, "spell/%s.%s.spl", 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) { // Try loading the ASCII version. vim_snprintf((char *)fname_enc, sizeof(fname_enc) - 5, "spell/%s.ascii.spl", lang); - 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 && round == 1 && apply_autocmds(EVENT_SPELLFILEMISSING, lang, @@ -2354,7 +2354,7 @@ static void spell_load_lang(char_u *lang) } else if (sl.sl_slang != NULL) { // 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/nvim/syntax.c b/src/nvim/syntax.c index 05141eaf1e..8792e80bcf 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -4208,7 +4208,7 @@ static void syn_cmd_include(exarg_T *eap, int syncing) 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; @@ -6027,7 +6027,7 @@ init_highlight ( EMSG(_("E679: recursive loop loading syncolor.vim")); else { ++recursive; - (void)source_runtime((char_u *)"syntax/syncolor.vim", TRUE); + (void)source_runtime((char_u *)"syntax/syncolor.vim", DIP_ALL); --recursive; } } @@ -6052,7 +6052,7 @@ int load_colors(char_u *name) recursive = TRUE; buf = xmalloc(STRLEN(name) + 12); sprintf((char *)buf, "colors/%s.vim", name); - retval = source_runtime(buf, FALSE); + retval = source_runtime(buf, DIP_START + DIP_OPT); xfree(buf); apply_autocmds(EVENT_COLORSCHEME, name, curbuf->b_fname, FALSE, curbuf); diff --git a/src/nvim/tag.c b/src/nvim/tag.c index 5d15196784..dfecfb776d 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -2023,9 +2023,8 @@ get_tagfname ( if (first) { ga_clear_strings(&tag_fnames); ga_init(&tag_fnames, (int)sizeof(char_u *), 10); - do_in_runtimepath((char_u *) - "doc/tags doc/tags-??" - , TRUE, found_tagfile_cb, NULL); + do_in_runtimepath((char_u *)"doc/tags doc/tags-??", DIP_ALL, + found_tagfile_cb, NULL); } if (tnp->tn_hf_idx >= tag_fnames.ga_len) { diff --git a/src/nvim/version.c b/src/nvim/version.c index e44b4441d0..9b4221863c 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -143,7 +143,7 @@ static int included_patches[] = { // 1555 NA // 1554, // 1553, - // 1552, + 1552, 1551, 1550, // 1549, diff --git a/src/nvim/vim.h b/src/nvim/vim.h index 745888af6a..47c5a0465a 100644 --- a/src/nvim/vim.h +++ b/src/nvim/vim.h @@ -308,9 +308,11 @@ enum { # define SET_NO_HLSEARCH(flag) no_hlsearch = (flag); set_vim_var_nr( \ VV_HLSEARCH, !no_hlsearch && p_hls) -// 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 +// Used for flags in do_in_path() +#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 /* NVIM_VIM_H */ |