vim-patch:8.0.0878: no completion for :mapclear

Problem:    No completion for :mapclear.
Solution:   Add completion (Nobuhiro Takasaki et al. closes vim/vim#1943)
cae92dc3d5
This commit is contained in:
Jan Edmund Lazo 2018-08-16 10:24:49 -04:00
parent b5cfac0894
commit 6531b175ad
6 changed files with 31 additions and 0 deletions

View File

@ -4099,6 +4099,7 @@ getcompletion({pat}, {type} [, {filtered}]) *getcompletion()*
highlight highlight groups highlight highlight groups
history :history suboptions history :history suboptions
locale locale names (as output of locale -a) locale locale names (as output of locale -a)
mapclear buffer argument
mapping mapping name mapping mapping name
menu menus menu menus
messages |:messages| suboptions messages |:messages| suboptions

View File

@ -1227,6 +1227,7 @@ completion can be enabled:
-complete=highlight highlight groups -complete=highlight highlight groups
-complete=history :history suboptions -complete=history :history suboptions
-complete=locale locale names (as output of locale -a) -complete=locale locale names (as output of locale -a)
-complete=mapclear buffer argument
-complete=mapping mapping name -complete=mapping mapping name
-complete=menu menus -complete=menu menus
-complete=messages |:messages| suboptions -complete=messages |:messages| suboptions

View File

@ -3350,6 +3350,19 @@ const char * set_one_cmd_context(
case CMD_xunmap: case CMD_xunmap:
return (const char *)set_context_in_map_cmd( return (const char *)set_context_in_map_cmd(
xp, (char_u *)cmd, (char_u *)arg, forceit, false, true, ea.cmdidx); 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_abbreviate: case CMD_noreabbrev:
case CMD_cabbrev: case CMD_cnoreabbrev: case CMD_cabbrev: case CMD_cnoreabbrev:
case CMD_iabbrev: case CMD_inoreabbrev: case CMD_iabbrev: case CMD_inoreabbrev:
@ -4870,6 +4883,7 @@ static const char *command_complete[] =
#ifdef HAVE_WORKING_LIBINTL #ifdef HAVE_WORKING_LIBINTL
[EXPAND_LOCALES] = "locale", [EXPAND_LOCALES] = "locale",
#endif #endif
[EXPAND_MAPCLEAR] = "mapclear",
[EXPAND_MAPPINGS] = "mapping", [EXPAND_MAPPINGS] = "mapping",
[EXPAND_MENUS] = "menu", [EXPAND_MENUS] = "menu",
[EXPAND_MESSAGES] = "messages", [EXPAND_MESSAGES] = "messages",
@ -9655,6 +9669,14 @@ char_u *get_messages_arg(expand_T *xp FUNC_ATTR_UNUSED, int idx)
return NULL; return NULL;
} }
char_u *get_mapclear_arg(expand_T *xp FUNC_ATTR_UNUSED, int idx)
{
if (idx == 0) {
return (char_u *)"<buffer>";
}
return NULL;
}
static TriState filetype_detect = kNone; static TriState filetype_detect = kNone;
static TriState filetype_plugin = kNone; static TriState filetype_plugin = kNone;
static TriState filetype_indent = kNone; static TriState filetype_indent = kNone;

View File

@ -4756,6 +4756,7 @@ ExpandFromContext (
} tab[] = { } tab[] = {
{ EXPAND_COMMANDS, get_command_name, false, true }, { EXPAND_COMMANDS, get_command_name, false, true },
{ EXPAND_BEHAVE, get_behave_arg, true, true }, { EXPAND_BEHAVE, get_behave_arg, true, true },
{ EXPAND_MAPCLEAR, get_mapclear_arg, true, true },
{ EXPAND_MESSAGES, get_messages_arg, true, true }, { EXPAND_MESSAGES, get_messages_arg, true, true },
{ EXPAND_HISTORY, get_history_arg, true, true }, { EXPAND_HISTORY, get_history_arg, true, true },
{ EXPAND_USER_COMMANDS, get_user_commands, false, true }, { EXPAND_USER_COMMANDS, get_user_commands, false, true },

View File

@ -222,6 +222,11 @@ func Test_getcompletion()
let l = getcompletion('not', 'messages') let l = getcompletion('not', 'messages')
call assert_equal([], l) call assert_equal([], l)
let l = getcompletion('', 'mapclear')
call assert_true(index(l, '<buffer>') >= 0)
let l = getcompletion('not', 'mapclear')
call assert_equal([], l)
if has('cscope') if has('cscope')
let l = getcompletion('', 'cscope') let l = getcompletion('', 'cscope')
let cmds = ['add', 'find', 'help', 'kill', 'reset', 'show'] let cmds = ['add', 'find', 'help', 'kill', 'reset', 'show']

View File

@ -155,6 +155,7 @@ enum {
EXPAND_USER_ADDR_TYPE, EXPAND_USER_ADDR_TYPE,
EXPAND_PACKADD, EXPAND_PACKADD,
EXPAND_MESSAGES, EXPAND_MESSAGES,
EXPAND_MAPCLEAR,
EXPAND_CHECKHEALTH, EXPAND_CHECKHEALTH,
}; };