diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index cfc3b70443..900f54c5b9 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -4099,6 +4099,7 @@ getcompletion({pat}, {type} [, {filtered}]) *getcompletion()* highlight highlight groups history :history suboptions locale locale names (as output of locale -a) + mapclear buffer argument mapping mapping name menu menus messages |:messages| suboptions diff --git a/runtime/doc/map.txt b/runtime/doc/map.txt index 804b7410f6..44c6196d53 100644 --- a/runtime/doc/map.txt +++ b/runtime/doc/map.txt @@ -1227,6 +1227,7 @@ completion can be enabled: -complete=highlight highlight groups -complete=history :history suboptions -complete=locale locale names (as output of locale -a) + -complete=mapclear buffer argument -complete=mapping mapping name -complete=menu menus -complete=messages |:messages| suboptions diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index c31242f2ac..df9f5774bc 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -3350,6 +3350,19 @@ const char * set_one_cmd_context( case CMD_xunmap: return (const char *)set_context_in_map_cmd( xp, (char_u *)cmd, (char_u *)arg, forceit, false, true, ea.cmdidx); + case CMD_mapclear: + case CMD_nmapclear: + case CMD_vmapclear: + case CMD_omapclear: + case CMD_imapclear: + case CMD_cmapclear: + case CMD_lmapclear: + case CMD_smapclear: + case CMD_xmapclear: + xp->xp_context = EXPAND_MAPCLEAR; + xp->xp_pattern = (char_u *)arg; + break; + case CMD_abbreviate: case CMD_noreabbrev: case CMD_cabbrev: case CMD_cnoreabbrev: case CMD_iabbrev: case CMD_inoreabbrev: @@ -4870,6 +4883,7 @@ static const char *command_complete[] = #ifdef HAVE_WORKING_LIBINTL [EXPAND_LOCALES] = "locale", #endif + [EXPAND_MAPCLEAR] = "mapclear", [EXPAND_MAPPINGS] = "mapping", [EXPAND_MENUS] = "menu", [EXPAND_MESSAGES] = "messages", @@ -9655,6 +9669,14 @@ char_u *get_messages_arg(expand_T *xp FUNC_ATTR_UNUSED, int idx) return NULL; } +char_u *get_mapclear_arg(expand_T *xp FUNC_ATTR_UNUSED, int idx) +{ + if (idx == 0) { + return (char_u *)""; + } + return NULL; +} + static TriState filetype_detect = kNone; static TriState filetype_plugin = kNone; static TriState filetype_indent = kNone; diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 1810056a4a..e8a85e7cf6 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -4756,6 +4756,7 @@ ExpandFromContext ( } tab[] = { { EXPAND_COMMANDS, get_command_name, false, true }, { EXPAND_BEHAVE, get_behave_arg, true, true }, + { EXPAND_MAPCLEAR, get_mapclear_arg, true, true }, { EXPAND_MESSAGES, get_messages_arg, true, true }, { EXPAND_HISTORY, get_history_arg, true, true }, { EXPAND_USER_COMMANDS, get_user_commands, false, true }, diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim index 5a43838218..a93beac4ad 100644 --- a/src/nvim/testdir/test_cmdline.vim +++ b/src/nvim/testdir/test_cmdline.vim @@ -222,6 +222,11 @@ func Test_getcompletion() let l = getcompletion('not', 'messages') call assert_equal([], l) + let l = getcompletion('', 'mapclear') + call assert_true(index(l, '') >= 0) + let l = getcompletion('not', 'mapclear') + call assert_equal([], l) + if has('cscope') let l = getcompletion('', 'cscope') let cmds = ['add', 'find', 'help', 'kill', 'reset', 'show'] diff --git a/src/nvim/vim.h b/src/nvim/vim.h index bddf092789..93cc58524e 100644 --- a/src/nvim/vim.h +++ b/src/nvim/vim.h @@ -155,6 +155,7 @@ enum { EXPAND_USER_ADDR_TYPE, EXPAND_PACKADD, EXPAND_MESSAGES, + EXPAND_MAPCLEAR, EXPAND_CHECKHEALTH, };