mirror of
https://github.com/neovim/neovim.git
synced 2025-10-01 07:28:34 +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);
|
||||
if (xp->xp_context == EXPAND_COLORS) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
return ExpandUserList(xp, num_file, file);
|
||||
@@ -4195,12 +4195,16 @@ static int ExpandUserList(expand_T *xp, int *num_file, char_u ***file)
|
||||
return OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Expand color scheme, compiler or filetype names:
|
||||
* 'runtimepath'/{dirnames}/{pat}.vim
|
||||
* "dirnames" is an array with one or more directory names.
|
||||
*/
|
||||
static int ExpandRTDir(char_u *pat, int *num_file, char_u ***file, char *dirnames[])
|
||||
/// Expand color scheme, compiler or filetype names.
|
||||
/// Search from 'runtimepath':
|
||||
/// 'runtimepath'/{dirnames}/{pat}.vim
|
||||
/// When "flags" has DIP_START: search also from 'start' of 'packpath':
|
||||
/// 'packpath'/pack/ * /start/ * /{dirnames}/{pat}.vim
|
||||
/// 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;
|
||||
*file = NULL;
|
||||
@@ -4217,6 +4221,26 @@ static int ExpandRTDir(char_u *pat, int *num_file, char_u ***file, char *dirname
|
||||
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++) {
|
||||
char_u *match = ((char_u **)ga.ga_data)[i];
|
||||
char_u *s = match;
|
||||
|
@@ -141,7 +141,7 @@ static int included_patches[] = {
|
||||
// 1557,
|
||||
// 1556 NA
|
||||
// 1555 NA
|
||||
// 1554,
|
||||
1554,
|
||||
1553,
|
||||
1552,
|
||||
1551,
|
||||
|
@@ -271,5 +271,52 @@ describe('packadd', function()
|
||||
:packadd ^ |
|
||||
]=])
|
||||
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)
|
||||
|
Reference in New Issue
Block a user