vim-patch:9.1.0010: Keymap completion is not available (#26888)

Problem:  Keymap completion is not available
Solution: Add keymap completion (Doug Kearns)

Add keymap completion to the 'keymap' option, user commands and builtin
completion functions.

closes: vim/vim#13692

81642d9d6f

Co-authored-by: Doug Kearns <dougkearns@gmail.com>
This commit is contained in:
zeertzjq
2024-01-05 08:23:51 +08:00
committed by GitHub
parent 88eb0ad149
commit dab5844082
10 changed files with 31 additions and 0 deletions

View File

@@ -99,6 +99,7 @@ static bool cmdline_fuzzy_completion_supported(const expand_T *const xp)
&& xp->xp_context != EXPAND_FILES_IN_PATH
&& xp->xp_context != EXPAND_FILETYPE
&& xp->xp_context != EXPAND_HELP
&& xp->xp_context != EXPAND_KEYMAP
&& xp->xp_context != EXPAND_LUA
&& xp->xp_context != EXPAND_OLD_SETTING
&& xp->xp_context != EXPAND_STRING_SETTING
@@ -1215,6 +1216,7 @@ char *addstar(char *fname, size_t len, int context)
|| context == EXPAND_COMPILER
|| context == EXPAND_OWNSYNTAX
|| context == EXPAND_FILETYPE
|| context == EXPAND_KEYMAP
|| context == EXPAND_PACKADD
|| context == EXPAND_RUNTIME
|| ((context == EXPAND_TAGS_LISTFILES || context == EXPAND_TAGS)
@@ -2741,6 +2743,10 @@ static int ExpandFromContext(expand_T *xp, char *pat, char ***matches, int *numM
char *directories[] = { "syntax", "indent", "ftplugin", NULL };
return ExpandRTDir(pat, 0, numMatches, matches, directories);
}
if (xp->xp_context == EXPAND_KEYMAP) {
char *directories[] = { "keymap", NULL };
return ExpandRTDir(pat, 0, numMatches, matches, directories);
}
if (xp->xp_context == EXPAND_USER_LIST) {
return ExpandUserList(xp, matches, numMatches);
}

View File

@@ -105,6 +105,7 @@ enum {
EXPAND_STRING_SETTING,
EXPAND_SETTING_SUBTRACT,
EXPAND_ARGOPT,
EXPAND_KEYMAP,
EXPAND_CHECKHEALTH,
EXPAND_LUA,
};

View File

@@ -3609,6 +3609,7 @@ M.funcs = {
help help subjects
highlight highlight groups
history |:history| suboptions
keymap keyboard mappings
locale locale names (as output of locale -a)
mapclear buffer argument
mapping mapping name

View File

@@ -5461,6 +5461,10 @@ void set_context_in_set_cmd(expand_T *xp, char *arg, int opt_flags)
xp->xp_context = EXPAND_FILETYPE;
return;
}
if (options[opt_idx].var == &p_keymap) {
xp->xp_context = EXPAND_KEYMAP;
return;
}
// Now pick. If the option has a custom expander, use that. Otherwise, just
// fill with the existing option value.

View File

@@ -75,6 +75,7 @@ static const char *command_complete[] = {
[EXPAND_HELP] = "help",
[EXPAND_HIGHLIGHT] = "highlight",
[EXPAND_HISTORY] = "history",
[EXPAND_KEYMAP] = "keymap",
#ifdef HAVE_WORKING_LIBINTL
[EXPAND_LOCALES] = "locale",
#endif