vim-patch:8.0.1649: no completion for argument list commands

Problem:    No completion for argument list commands.
Solution:   Add arglist completion. (Yegappan Lakshmanan, closes vim/vim#2706)
cd43effeca
This commit is contained in:
Jan Edmund Lazo 2018-08-16 11:28:05 -04:00
parent be552c8340
commit 1dcdac013e
7 changed files with 26 additions and 0 deletions

View File

@ -4079,6 +4079,7 @@ getcompletion({pat}, {type} [, {filtered}]) *getcompletion()*
specifies what for. The following completion types are specifies what for. The following completion types are
supported: supported:
arglist file names in argument list
augroup autocmd groups augroup autocmd groups
buffer buffer names buffer buffer names
behave :behave suboptions behave :behave suboptions

View File

@ -1208,6 +1208,7 @@ By default, the arguments of user defined commands do not undergo completion.
However, by specifying one or the other of the following attributes, argument However, by specifying one or the other of the following attributes, argument
completion can be enabled: completion can be enabled:
-complete=arglist file names in argument list
-complete=augroup autocmd groups -complete=augroup autocmd groups
-complete=buffer buffer names -complete=buffer buffer names
-complete=behave :behave suboptions -complete=behave :behave suboptions

View File

@ -2254,6 +2254,15 @@ static int alist_add_list(int count, char_u **files, int after)
} }
} }
// Function given to ExpandGeneric() to obtain the possible arguments of the
// argedit and argdelete commands.
char_u *get_arglist_name(expand_T *xp FUNC_ATTR_UNUSED, int idx)
{
if (idx >= ARGCOUNT) {
return NULL;
}
return alist_name(&ARGLIST[idx]);
}
/// ":compiler[!] {name}" /// ":compiler[!] {name}"
void ex_compiler(exarg_T *eap) void ex_compiler(exarg_T *eap)

View File

@ -3454,6 +3454,13 @@ const char * set_one_cmd_context(
xp->xp_pattern = (char_u *)arg; xp->xp_pattern = (char_u *)arg;
break; break;
case CMD_argdelete:
while ((xp->xp_pattern = vim_strchr((const char_u *)arg, ' ')) != NULL) {
arg = (const char *)(xp->xp_pattern + 1);
}
xp->xp_context = EXPAND_ARGLIST;
xp->xp_pattern = (char_u *)arg;
break;
default: default:
break; break;
@ -4859,6 +4866,7 @@ static struct {
*/ */
static const char *command_complete[] = static const char *command_complete[] =
{ {
[EXPAND_ARGLIST] = "arglist",
[EXPAND_AUGROUP] = "augroup", [EXPAND_AUGROUP] = "augroup",
[EXPAND_BEHAVE] = "behave", [EXPAND_BEHAVE] = "behave",
[EXPAND_BUFFERS] = "buffer", [EXPAND_BUFFERS] = "buffer",

View File

@ -4784,6 +4784,7 @@ ExpandFromContext (
#endif #endif
{ EXPAND_ENV_VARS, get_env_name, true, true }, { EXPAND_ENV_VARS, get_env_name, true, true },
{ EXPAND_USER, get_users, true, false }, { EXPAND_USER, get_users, true, false },
{ EXPAND_ARGLIST, get_arglist_name, true, false },
}; };
int i; int i;

View File

@ -137,6 +137,11 @@ func Test_getcompletion()
let l = getcompletion('v:notexists', 'var') let l = getcompletion('v:notexists', 'var')
call assert_equal([], l) call assert_equal([], l)
args a.c b.c
let l = getcompletion('', 'arglist')
call assert_equal(['a.c', 'b.c'], l)
%argdelete
let l = getcompletion('', 'augroup') let l = getcompletion('', 'augroup')
call assert_true(index(l, 'END') >= 0) call assert_true(index(l, 'END') >= 0)
let l = getcompletion('blahblah', 'augroup') let l = getcompletion('blahblah', 'augroup')

View File

@ -156,6 +156,7 @@ enum {
EXPAND_PACKADD, EXPAND_PACKADD,
EXPAND_MESSAGES, EXPAND_MESSAGES,
EXPAND_MAPCLEAR, EXPAND_MAPCLEAR,
EXPAND_ARGLIST,
EXPAND_CHECKHEALTH, EXPAND_CHECKHEALTH,
}; };