mirror of
https://github.com/neovim/neovim.git
synced 2025-09-22 03:08:27 +00:00
vim-patch:7.4.1552
Problem: ":colorscheme" does not use 'packpath'.
Solution: Also use in "start" and "opt" directories in 'packpath'.
7f8989dd8a
This commit is contained in:
@@ -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");
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
|
@@ -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.
|
||||
|
@@ -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
|
||||
|
@@ -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;
|
||||
|
@@ -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);
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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);
|
||||
|
||||
|
@@ -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) {
|
||||
|
@@ -143,7 +143,7 @@ static int included_patches[] = {
|
||||
// 1555 NA
|
||||
// 1554,
|
||||
// 1553,
|
||||
// 1552,
|
||||
1552,
|
||||
1551,
|
||||
1550,
|
||||
// 1549,
|
||||
|
@@ -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 */
|
||||
|
@@ -107,6 +107,26 @@ describe('packadd', function()
|
||||
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
|
||||
]=])
|
||||
call('SetUp')
|
||||
end)
|
||||
@@ -135,6 +155,11 @@ describe('packadd', function()
|
||||
expected_empty()
|
||||
end)
|
||||
|
||||
it('works with colorschemes', function()
|
||||
call('Test_colorscheme')
|
||||
expected_empty()
|
||||
end)
|
||||
|
||||
describe('command line completion', function()
|
||||
local Screen = require('test.functional.ui.screen')
|
||||
local screen
|
||||
|
Reference in New Issue
Block a user