fix(completion): include lua syntaxes in :ownsyntax completion (#21941)

This just removes DIP_LUA and always executes its branches.
Also add tests for cmdline completion for other lua runtime files.
This commit is contained in:
zeertzjq
2023-01-22 11:19:58 +08:00
committed by GitHub
parent 108452aaba
commit 18fb669b9b
4 changed files with 56 additions and 51 deletions

View File

@@ -1175,12 +1175,11 @@ void ex_packadd(exarg_T *eap)
/// 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
/// When "flags" has DIP_LUA: search also performed for .lua files
/// 'runtimepath'/{dirnames}/{pat}.(vim|lua)
/// When "flags" has DIP_START: search also from "start" of 'packpath':
/// 'packpath'/pack/*/start/*/{dirnames}/{pat}.(vim|lua)
/// When "flags" has DIP_OPT: search also from "opt" of 'packpath':
/// 'packpath'/pack/*/opt/*/{dirnames}/{pat}.(vim|lua)
/// "dirnames" is an array with one or more directory names.
int ExpandRTDir(char *pat, int flags, int *num_file, char ***file, char *dirnames[])
{
@@ -1197,10 +1196,8 @@ int ExpandRTDir(char *pat, int flags, int *num_file, char ***file, char *dirname
char *s = xmalloc(size);
snprintf(s, size, "%s/%s*.vim", dirnames[i], pat);
globpath(p_rtp, s, &ga, 0);
if (flags & DIP_LUA) {
snprintf(s, size, "%s/%s*.lua", dirnames[i], pat);
globpath(p_rtp, s, &ga, 0);
}
snprintf(s, size, "%s/%s*.lua", dirnames[i], pat);
globpath(p_rtp, s, &ga, 0);
xfree(s);
}
@@ -1210,10 +1207,8 @@ int ExpandRTDir(char *pat, int flags, int *num_file, char ***file, char *dirname
char *s = xmalloc(size);
snprintf(s, size, "pack/*/start/*/%s/%s*.vim", dirnames[i], pat); // NOLINT
globpath(p_pp, s, &ga, 0);
if (flags & DIP_LUA) {
snprintf(s, size, "pack/*/start/*/%s/%s*.lua", dirnames[i], pat); // NOLINT
globpath(p_pp, s, &ga, 0);
}
snprintf(s, size, "pack/*/start/*/%s/%s*.lua", dirnames[i], pat); // NOLINT
globpath(p_pp, s, &ga, 0);
xfree(s);
}
@@ -1222,10 +1217,8 @@ int ExpandRTDir(char *pat, int flags, int *num_file, char ***file, char *dirname
char *s = xmalloc(size);
snprintf(s, size, "start/*/%s/%s*.vim", dirnames[i], pat); // NOLINT
globpath(p_pp, s, &ga, 0);
if (flags & DIP_LUA) {
snprintf(s, size, "start/*/%s/%s*.lua", dirnames[i], pat); // NOLINT
globpath(p_pp, s, &ga, 0);
}
snprintf(s, size, "start/*/%s/%s*.lua", dirnames[i], pat); // NOLINT
globpath(p_pp, s, &ga, 0);
xfree(s);
}
}
@@ -1236,10 +1229,8 @@ int ExpandRTDir(char *pat, int flags, int *num_file, char ***file, char *dirname
char *s = xmalloc(size);
snprintf(s, size, "pack/*/opt/*/%s/%s*.vim", dirnames[i], pat); // NOLINT
globpath(p_pp, s, &ga, 0);
if (flags & DIP_LUA) {
snprintf(s, size, "pack/*/opt/*/%s/%s*.lua", dirnames[i], pat); // NOLINT
globpath(p_pp, s, &ga, 0);
}
snprintf(s, size, "pack/*/opt/*/%s/%s*.lua", dirnames[i], pat); // NOLINT
globpath(p_pp, s, &ga, 0);
xfree(s);
}
@@ -1248,10 +1239,8 @@ int ExpandRTDir(char *pat, int flags, int *num_file, char ***file, char *dirname
char *s = xmalloc(size);
snprintf(s, size, "opt/*/%s/%s*.vim", dirnames[i], pat); // NOLINT
globpath(p_pp, s, &ga, 0);
if (flags & DIP_LUA) {
snprintf(s, size, "opt/*/%s/%s*.lua", dirnames[i], pat); // NOLINT
globpath(p_pp, s, &ga, 0);
}
snprintf(s, size, "opt/*/%s/%s*.lua", dirnames[i], pat); // NOLINT
globpath(p_pp, s, &ga, 0);
xfree(s);
}
}
@@ -1261,8 +1250,7 @@ int ExpandRTDir(char *pat, int flags, int *num_file, char ***file, char *dirname
char *s = match;
char *e = s + strlen(s);
if (e - s > 4 && (STRNICMP(e - 4, ".vim", 4) == 0
|| ((flags & DIP_LUA)
&& STRNICMP(e - 4, ".lua", 4) == 0))) {
|| STRNICMP(e - 4, ".lua", 4) == 0)) {
e -= 4;
for (s = e; s > match; MB_PTR_BACK(match, s)) {
if (vim_ispathsep(*s)) {