Mercurial > vim
changeset 13551:1fd0f8392946 v8.0.1649
patch 8.0.1649: no completion for argument list commands
commit https://github.com/vim/vim/commit/cd43effecab02c6c28b1c4a3a14f91b8c3f26c0d
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Mar 29 15:55:38 2018 +0200
patch 8.0.1649: no completion for argument list commands
Problem: No completion for argument list commands.
Solution: Add arglist completion. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/2706)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 29 Mar 2018 16:00:07 +0200 |
parents | 30faaab193e0 |
children | 5417164ac275 |
files | runtime/doc/eval.txt runtime/doc/map.txt src/ex_cmds2.c src/ex_docmd.c src/ex_getln.c src/proto/ex_cmds2.pro src/testdir/test_cmdline.vim src/version.c src/vim.h |
diffstat | 9 files changed, 35 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -4469,6 +4469,7 @@ getcompletion({pat}, {type} [, {filtered specifies what for. The following completion types are supported: + arglist file names in argument list augroup autocmd groups buffer buffer names behave :behave suboptions
--- a/runtime/doc/map.txt +++ b/runtime/doc/map.txt @@ -1272,6 +1272,7 @@ By default, the arguments of user define However, by specifying one or the other of the following attributes, argument completion can be enabled: + -complete=arglist file names in argument list -complete=augroup autocmd groups -complete=buffer buffer names -complete=behave :behave suboptions
--- a/src/ex_cmds2.c +++ b/src/ex_cmds2.c @@ -3314,6 +3314,21 @@ alist_add_list( #endif /* FEAT_LISTCMDS */ +#if defined(FEAT_CMDL_COMPL) || defined(PROTO) +/* + * Function given to ExpandGeneric() to obtain the possible arguments of the + * argedit and argdelete commands. + */ + char_u * +get_arglist_name(expand_T *xp UNUSED, int idx) +{ + if (idx >= ARGCOUNT) + return NULL; + + return alist_name(&ARGLIST[idx]); +} +#endif + #ifdef FEAT_EVAL /* * ":compiler[!] {name}"
--- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -4293,6 +4293,13 @@ set_one_cmd_context( break; #endif + case CMD_argdelete: + while ((xp->xp_pattern = vim_strchr(arg, ' ')) != NULL) + arg = xp->xp_pattern + 1; + xp->xp_context = EXPAND_ARGLIST; + xp->xp_pattern = arg; + break; + #endif /* FEAT_CMDL_COMPL */ default: @@ -5879,6 +5886,7 @@ static struct char *name; } command_complete[] = { + {EXPAND_ARGLIST, "arglist"}, {EXPAND_AUGROUP, "augroup"}, {EXPAND_BEHAVE, "behave"}, {EXPAND_BUFFERS, "buffer"},
--- a/src/ex_getln.c +++ b/src/ex_getln.c @@ -4989,6 +4989,7 @@ ExpandFromContext( #endif {EXPAND_ENV_VARS, get_env_name, TRUE, TRUE}, {EXPAND_USER, get_users, TRUE, FALSE}, + {EXPAND_ARGLIST, get_arglist_name, TRUE, FALSE}, }; int i;
--- a/src/proto/ex_cmds2.pro +++ b/src/proto/ex_cmds2.pro @@ -67,6 +67,7 @@ void ex_argedit(exarg_T *eap); void ex_argadd(exarg_T *eap); void ex_argdelete(exarg_T *eap); void ex_listdo(exarg_T *eap); +char_u *get_arglist_name(expand_T *xp, int idx); void ex_compiler(exarg_T *eap); void ex_runtime(exarg_T *eap); int do_in_path(char_u *path, char_u *name, int flags, void (*callback)(char_u *fname, void *ck), void *cookie);
--- a/src/testdir/test_cmdline.vim +++ b/src/testdir/test_cmdline.vim @@ -137,6 +137,11 @@ func Test_getcompletion() let l = getcompletion('v:notexists', 'var') 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') call assert_true(index(l, 'END') >= 0) let l = getcompletion('blahblah', 'augroup')