diff options
author | Jan Edmund Lazo <janedmundlazo@hotmail.com> | 2018-08-16 11:28:05 -0400 |
---|---|---|
committer | Jan Edmund Lazo <janedmundlazo@hotmail.com> | 2018-08-16 11:47:56 -0400 |
commit | 1dcdac013e4beea2a327e1fb98ac4627bbe174ec (patch) | |
tree | 4a430c1a18bc73ea9b5d3c28642cc4fae2d088a8 | |
parent | be552c8340615a4c9e670bc77df5e6016214d4f4 (diff) | |
download | rneovim-1dcdac013e4beea2a327e1fb98ac4627bbe174ec.tar.gz rneovim-1dcdac013e4beea2a327e1fb98ac4627bbe174ec.tar.bz2 rneovim-1dcdac013e4beea2a327e1fb98ac4627bbe174ec.zip |
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)
https://github.com/vim/vim/commit/cd43effecab02c6c28b1c4a3a14f91b8c3f26c0d
-rw-r--r-- | runtime/doc/eval.txt | 1 | ||||
-rw-r--r-- | runtime/doc/map.txt | 1 | ||||
-rw-r--r-- | src/nvim/ex_cmds2.c | 9 | ||||
-rw-r--r-- | src/nvim/ex_docmd.c | 8 | ||||
-rw-r--r-- | src/nvim/ex_getln.c | 1 | ||||
-rw-r--r-- | src/nvim/testdir/test_cmdline.vim | 5 | ||||
-rw-r--r-- | src/nvim/vim.h | 1 |
7 files changed, 26 insertions, 0 deletions
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 900f54c5b9..4d5a592190 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -4079,6 +4079,7 @@ getcompletion({pat}, {type} [, {filtered}]) *getcompletion()* specifies what for. The following completion types are supported: + arglist file names in argument list augroup autocmd groups buffer buffer names behave :behave suboptions diff --git a/runtime/doc/map.txt b/runtime/doc/map.txt index 44c6196d53..d630bf5652 100644 --- a/runtime/doc/map.txt +++ b/runtime/doc/map.txt @@ -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 completion can be enabled: + -complete=arglist file names in argument list -complete=augroup autocmd groups -complete=buffer buffer names -complete=behave :behave suboptions diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index 120278d3fb..c384d253b9 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -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}" void ex_compiler(exarg_T *eap) diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 5e5b6c382d..fe4de6f83d 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -3454,6 +3454,13 @@ const char * set_one_cmd_context( xp->xp_pattern = (char_u *)arg; 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: break; @@ -4859,6 +4866,7 @@ static struct { */ static const char *command_complete[] = { + [EXPAND_ARGLIST] = "arglist", [EXPAND_AUGROUP] = "augroup", [EXPAND_BEHAVE] = "behave", [EXPAND_BUFFERS] = "buffer", diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index e8a85e7cf6..0190cfabe5 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -4784,6 +4784,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; diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim index ac80dd383e..9ea80d73d4 100644 --- a/src/nvim/testdir/test_cmdline.vim +++ b/src/nvim/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') diff --git a/src/nvim/vim.h b/src/nvim/vim.h index 93cc58524e..767936ecee 100644 --- a/src/nvim/vim.h +++ b/src/nvim/vim.h @@ -156,6 +156,7 @@ enum { EXPAND_PACKADD, EXPAND_MESSAGES, EXPAND_MAPCLEAR, + EXPAND_ARGLIST, EXPAND_CHECKHEALTH, }; |