Skip to content

Commit cd43eff

Browse files
committed
patch 8.0.1649: no completion for argument list commands
Problem: No completion for argument list commands. Solution: Add arglist completion. (Yegappan Lakshmanan, closes #2706)
1 parent 1b2f61e commit cd43eff

9 files changed

Lines changed: 35 additions & 0 deletions

File tree

‎runtime/doc/eval.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4469,6 +4469,7 @@ getcompletion({pat}, {type} [, {filtered}]) *getcompletion()*
44694469
specifies what for. The following completion types are
44704470
supported:
44714471

4472+
arglist file names in argument list
44724473
augroup autocmd groups
44734474
buffer buffer names
44744475
behave :behave suboptions

‎runtime/doc/map.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1272,6 +1272,7 @@ By default, the arguments of user defined commands do not undergo completion.
12721272
However, by specifying one or the other of the following attributes, argument
12731273
completion can be enabled:
12741274

1275+
-complete=arglist file names in argument list
12751276
-complete=augroup autocmd groups
12761277
-complete=buffer buffer names
12771278
-complete=behave :behave suboptions

‎src/ex_cmds2.c‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3314,6 +3314,21 @@ alist_add_list(
33143314

33153315
#endif /* FEAT_LISTCMDS */
33163316

3317+
#if defined(FEAT_CMDL_COMPL) || defined(PROTO)
3318+
/*
3319+
* Function given to ExpandGeneric() to obtain the possible arguments of the
3320+
* argedit and argdelete commands.
3321+
*/
3322+
char_u *
3323+
get_arglist_name(expand_T *xp UNUSED, int idx)
3324+
{
3325+
if (idx >= ARGCOUNT)
3326+
return NULL;
3327+
3328+
return alist_name(&ARGLIST[idx]);
3329+
}
3330+
#endif
3331+
33173332
#ifdef FEAT_EVAL
33183333
/*
33193334
* ":compiler[!] {name}"

‎src/ex_docmd.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4293,6 +4293,13 @@ set_one_cmd_context(
42934293
break;
42944294
#endif
42954295

4296+
case CMD_argdelete:
4297+
while ((xp->xp_pattern = vim_strchr(arg, ' ')) != NULL)
4298+
arg = xp->xp_pattern + 1;
4299+
xp->xp_context = EXPAND_ARGLIST;
4300+
xp->xp_pattern = arg;
4301+
break;
4302+
42964303
#endif /* FEAT_CMDL_COMPL */
42974304

42984305
default:
@@ -5879,6 +5886,7 @@ static struct
58795886
char *name;
58805887
} command_complete[] =
58815888
{
5889+
{EXPAND_ARGLIST, "arglist"},
58825890
{EXPAND_AUGROUP, "augroup"},
58835891
{EXPAND_BEHAVE, "behave"},
58845892
{EXPAND_BUFFERS, "buffer"},

‎src/ex_getln.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4989,6 +4989,7 @@ ExpandFromContext(
49894989
#endif
49904990
{EXPAND_ENV_VARS, get_env_name, TRUE, TRUE},
49914991
{EXPAND_USER, get_users, TRUE, FALSE},
4992+
{EXPAND_ARGLIST, get_arglist_name, TRUE, FALSE},
49924993
};
49934994
int i;
49944995

‎src/proto/ex_cmds2.pro‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ void ex_argedit(exarg_T *eap);
6767
void ex_argadd(exarg_T *eap);
6868
void ex_argdelete(exarg_T *eap);
6969
void ex_listdo(exarg_T *eap);
70+
char_u *get_arglist_name(expand_T *xp, int idx);
7071
void ex_compiler(exarg_T *eap);
7172
void ex_runtime(exarg_T *eap);
7273
int do_in_path(char_u *path, char_u *name, int flags, void (*callback)(char_u *fname, void *ck), void *cookie);

‎src/testdir/test_cmdline.vim‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,11 @@ func Test_getcompletion()
137137
let l = getcompletion('v:notexists', 'var')
138138
call assert_equal([], l)
139139

140+
args a.c b.c
141+
let l = getcompletion('', 'arglist')
142+
call assert_equal(['a.c', 'b.c'], l)
143+
%argdelete
144+
140145
let l = getcompletion('', 'augroup')
141146
call assert_true(index(l, 'END') >= 0)
142147
let l = getcompletion('blahblah', 'augroup')

‎src/version.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,8 @@ static char *(features[]) =
766766

767767
static int included_patches[] =
768768
{ /* Add new patch number below this line */
769+
/**/
770+
1649,
769771
/**/
770772
1648,
771773
/**/

‎src/vim.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,7 @@ extern int (*dyn_libintl_putenv)(const char *envstring);
781781
#define EXPAND_PACKADD 45
782782
#define EXPAND_MESSAGES 46
783783
#define EXPAND_MAPCLEAR 47
784+
#define EXPAND_ARGLIST 48
784785

785786
/* Values for exmode_active (0 is no exmode) */
786787
#define EXMODE_NORMAL 1

0 commit comments

Comments
 (0)