mirror of
https://github.com/neovim/neovim.git
synced 2025-10-01 15:38:33 +00:00
vim-patch:7.4.1554
Problem: Completion for :colorscheme does not use 'packpath'.
Solution: Make it work, add a test. (Hirohito Higashi)
52f9c19015
This commit is contained in:
@@ -3796,19 +3796,19 @@ ExpandFromContext (
|
|||||||
return expand_tags(xp->xp_context == EXPAND_TAGS, pat, num_file, file);
|
return expand_tags(xp->xp_context == EXPAND_TAGS, pat, num_file, file);
|
||||||
if (xp->xp_context == EXPAND_COLORS) {
|
if (xp->xp_context == EXPAND_COLORS) {
|
||||||
char *directories[] = {"colors", NULL};
|
char *directories[] = {"colors", NULL};
|
||||||
return ExpandRTDir(pat, num_file, file, directories);
|
return ExpandRTDir(pat, DIP_START + DIP_OPT, num_file, file, directories);
|
||||||
}
|
}
|
||||||
if (xp->xp_context == EXPAND_COMPILER) {
|
if (xp->xp_context == EXPAND_COMPILER) {
|
||||||
char *directories[] = {"compiler", NULL};
|
char *directories[] = {"compiler", NULL};
|
||||||
return ExpandRTDir(pat, num_file, file, directories);
|
return ExpandRTDir(pat, 0, num_file, file, directories);
|
||||||
}
|
}
|
||||||
if (xp->xp_context == EXPAND_OWNSYNTAX) {
|
if (xp->xp_context == EXPAND_OWNSYNTAX) {
|
||||||
char *directories[] = {"syntax", NULL};
|
char *directories[] = {"syntax", NULL};
|
||||||
return ExpandRTDir(pat, num_file, file, directories);
|
return ExpandRTDir(pat, 0, num_file, file, directories);
|
||||||
}
|
}
|
||||||
if (xp->xp_context == EXPAND_FILETYPE) {
|
if (xp->xp_context == EXPAND_FILETYPE) {
|
||||||
char *directories[] = {"syntax", "indent", "ftplugin", NULL};
|
char *directories[] = {"syntax", "indent", "ftplugin", NULL};
|
||||||
return ExpandRTDir(pat, num_file, file, directories);
|
return ExpandRTDir(pat, 0, num_file, file, directories);
|
||||||
}
|
}
|
||||||
if (xp->xp_context == EXPAND_USER_LIST) {
|
if (xp->xp_context == EXPAND_USER_LIST) {
|
||||||
return ExpandUserList(xp, num_file, file);
|
return ExpandUserList(xp, num_file, file);
|
||||||
@@ -4195,12 +4195,16 @@ static int ExpandUserList(expand_T *xp, int *num_file, char_u ***file)
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/// Expand color scheme, compiler or filetype names.
|
||||||
* Expand color scheme, compiler or filetype names:
|
/// Search from 'runtimepath':
|
||||||
* 'runtimepath'/{dirnames}/{pat}.vim
|
/// 'runtimepath'/{dirnames}/{pat}.vim
|
||||||
* "dirnames" is an array with one or more directory names.
|
/// When "flags" has DIP_START: search also from 'start' of 'packpath':
|
||||||
*/
|
/// 'packpath'/pack/ * /start/ * /{dirnames}/{pat}.vim
|
||||||
static int ExpandRTDir(char_u *pat, int *num_file, char_u ***file, char *dirnames[])
|
/// When "flags" has DIP_OPT: search also from 'opt' of 'packpath':
|
||||||
|
/// 'packpath'/pack/ * /opt/ * /{dirnames}/{pat}.vim
|
||||||
|
/// "dirnames" is an array with one or more directory names.
|
||||||
|
static int ExpandRTDir(char_u *pat, int flags, int *num_file, char_u ***file,
|
||||||
|
char *dirnames[])
|
||||||
{
|
{
|
||||||
*num_file = 0;
|
*num_file = 0;
|
||||||
*file = NULL;
|
*file = NULL;
|
||||||
@@ -4217,6 +4221,26 @@ static int ExpandRTDir(char_u *pat, int *num_file, char_u ***file, char *dirname
|
|||||||
xfree(s);
|
xfree(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (flags & DIP_START) {
|
||||||
|
for (int i = 0; dirnames[i] != NULL; i++) {
|
||||||
|
size_t size = STRLEN(dirnames[i]) + pat_len + 22;
|
||||||
|
char_u *s = xmalloc(size);
|
||||||
|
snprintf((char *)s, size, "pack/*/start/*/%s/%s*.vim", dirnames[i], pat);
|
||||||
|
globpath(p_pp, s, &ga, 0);
|
||||||
|
xfree(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flags & DIP_OPT) {
|
||||||
|
for (int i = 0; dirnames[i] != NULL; i++) {
|
||||||
|
size_t size = STRLEN(dirnames[i]) + pat_len + 20;
|
||||||
|
char_u *s = xmalloc(size);
|
||||||
|
snprintf((char *)s, size, "pack/*/opt/*/%s/%s*.vim", dirnames[i], pat);
|
||||||
|
globpath(p_pp, s, &ga, 0);
|
||||||
|
xfree(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < ga.ga_len; i++) {
|
for (int i = 0; i < ga.ga_len; i++) {
|
||||||
char_u *match = ((char_u **)ga.ga_data)[i];
|
char_u *match = ((char_u **)ga.ga_data)[i];
|
||||||
char_u *s = match;
|
char_u *s = match;
|
||||||
|
@@ -141,7 +141,7 @@ static int included_patches[] = {
|
|||||||
// 1557,
|
// 1557,
|
||||||
// 1556 NA
|
// 1556 NA
|
||||||
// 1555 NA
|
// 1555 NA
|
||||||
// 1554,
|
1554,
|
||||||
1553,
|
1553,
|
||||||
1552,
|
1552,
|
||||||
1551,
|
1551,
|
||||||
|
@@ -271,5 +271,52 @@ describe('packadd', function()
|
|||||||
:packadd ^ |
|
:packadd ^ |
|
||||||
]=])
|
]=])
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('works for colorschemes', function()
|
||||||
|
source([[
|
||||||
|
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']])
|
||||||
|
|
||||||
|
feed(':colorscheme <Tab>')
|
||||||
|
screen:expect([=[
|
||||||
|
|
|
||||||
|
~ |
|
||||||
|
~ |
|
||||||
|
{1:one}{2: three two }|
|
||||||
|
:colorscheme one^ |
|
||||||
|
]=])
|
||||||
|
feed('<Tab>')
|
||||||
|
screen:expect([=[
|
||||||
|
|
|
||||||
|
~ |
|
||||||
|
~ |
|
||||||
|
{2:one }{1:three}{2: two }|
|
||||||
|
:colorscheme three^ |
|
||||||
|
]=])
|
||||||
|
feed('<Tab>')
|
||||||
|
screen:expect([=[
|
||||||
|
|
|
||||||
|
~ |
|
||||||
|
~ |
|
||||||
|
{2:one three }{1:two}{2: }|
|
||||||
|
:colorscheme two^ |
|
||||||
|
]=])
|
||||||
|
feed('<Tab>')
|
||||||
|
screen:expect([=[
|
||||||
|
|
|
||||||
|
~ |
|
||||||
|
~ |
|
||||||
|
{2:one three two }|
|
||||||
|
:colorscheme ^ |
|
||||||
|
]=])
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
Reference in New Issue
Block a user