summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDoug Kearns <dougkearns@gmail.com>2024-01-04 22:37:44 +0100
committerChristian Brabandt <cb@256bit.org>2024-01-04 22:37:44 +0100
commit81642d9d6ff5cd6a90a012b1b98632ce51eeb1a8 (patch)
tree074b568c9b8d541d515a21c644d51f6ebce6f459 /src
parentf93b1c881a99fa847a1bafa71877d7e16f18e6ef (diff)
patch 9.1.0010: Keymap completion is not availablev9.1.0010
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: #13692 Signed-off-by: Doug Kearns <dougkearns@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
Diffstat (limited to 'src')
-rw-r--r--src/cmdexpand.c9
-rw-r--r--src/option.c7
-rw-r--r--src/testdir/test_cmdline.vim7
-rw-r--r--src/testdir/test_options.vim8
-rw-r--r--src/usercmd.c3
-rw-r--r--src/version.c2
-rw-r--r--src/vim.h1
7 files changed, 37 insertions, 0 deletions
diff --git a/src/cmdexpand.c b/src/cmdexpand.c
index 8bccaa3bb0..1008bf97e5 100644
--- a/src/cmdexpand.c
+++ b/src/cmdexpand.c
@@ -50,6 +50,7 @@ cmdline_fuzzy_completion_supported(expand_T *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_OLD_SETTING
&& xp->xp_context != EXPAND_STRING_SETTING
&& xp->xp_context != EXPAND_SETTING_SUBTRACT
@@ -1394,6 +1395,7 @@ addstar(
|| context == EXPAND_COMPILER
|| context == EXPAND_OWNSYNTAX
|| context == EXPAND_FILETYPE
+ || context == EXPAND_KEYMAP
|| context == EXPAND_PACKADD
|| context == EXPAND_RUNTIME
|| ((context == EXPAND_TAGS_LISTFILES
@@ -3131,6 +3133,13 @@ ExpandFromContext(
char *directories[] = {"syntax", "indent", "ftplugin", NULL};
return ExpandRTDir(pat, 0, numMatches, matches, directories);
}
+#ifdef FEAT_KEYMAP
+ if (xp->xp_context == EXPAND_KEYMAP)
+ {
+ char *directories[] = {"keymap", NULL};
+ return ExpandRTDir(pat, 0, numMatches, matches, directories);
+ }
+#endif
#if defined(FEAT_EVAL)
if (xp->xp_context == EXPAND_USER_LIST)
return ExpandUserList(xp, matches, numMatches);
diff --git a/src/option.c b/src/option.c
index 7cac89e5cf..2372c1aa9b 100644
--- a/src/option.c
+++ b/src/option.c
@@ -7412,6 +7412,13 @@ set_context_in_set_cmd(
xp->xp_context = EXPAND_FILETYPE;
return;
}
+#ifdef FEAT_KEYMAP
+ if (options[opt_idx].var == (char_u *)&p_keymap)
+ {
+ xp->xp_context = EXPAND_KEYMAP;
+ return;
+ }
+#endif
// Now pick. If the option has a custom expander, use that. Otherwise, just
// fill with the existing option value.
diff --git a/src/testdir/test_cmdline.vim b/src/testdir/test_cmdline.vim
index 33ff606424..4554712670 100644
--- a/src/testdir/test_cmdline.vim
+++ b/src/testdir/test_cmdline.vim
@@ -545,6 +545,13 @@ func Test_getcompletion()
let l = getcompletion('horse', 'filetype')
call assert_equal([], l)
+ if has('keymap')
+ let l = getcompletion('acc', 'keymap')
+ call assert_true(index(l, 'accents') >= 0)
+ let l = getcompletion('nullkeymap', 'keymap')
+ call assert_equal([], l)
+ endif
+
let l = getcompletion('z', 'syntax')
call assert_true(index(l, 'zimbu') >= 0)
let l = getcompletion('emacs', 'syntax')
diff --git a/src/testdir/test_options.vim b/src/testdir/test_options.vim
index 8c336abf7d..37dc20187e 100644
--- a/src/testdir/test_options.vim
+++ b/src/testdir/test_options.vim
@@ -435,6 +435,14 @@ func Test_set_completion()
call assert_equal('"set syntax=sshdconfig', @:)
call feedkeys(":set syntax=a\<C-A>\<C-B>\"\<CR>", 'xt')
call assert_equal('"set syntax=' .. getcompletion('a*', 'syntax')->join(), @:)
+
+ if has('keymap')
+ " Expand values for 'keymap'
+ call feedkeys(":set keymap=acc\<Tab>\<C-B>\"\<CR>", 'xt')
+ call assert_equal('"set keymap=accents', @:)
+ call feedkeys(":set keymap=a\<C-A>\<C-B>\"\<CR>", 'xt')
+ call assert_equal('"set keymap=' .. getcompletion('a*', 'keymap')->join(), @:)
+ endif
endfunc
" Test handling of expanding individual string option values
diff --git a/src/usercmd.c b/src/usercmd.c
index 04b341933a..e2c0114ca3 100644
--- a/src/usercmd.c
+++ b/src/usercmd.c
@@ -73,6 +73,9 @@ static struct
{EXPAND_HELP, "help"},
{EXPAND_HIGHLIGHT, "highlight"},
{EXPAND_HISTORY, "history"},
+#if defined(FEAT_KEYMAP)
+ {EXPAND_KEYMAP, "keymap"},
+#endif
#if defined(HAVE_LOCALE_H) || defined(X_LOCALE)
{EXPAND_LOCALES, "locale"},
#endif
diff --git a/src/version.c b/src/version.c
index 2e7f2871ea..c31fbf6358 100644
--- a/src/version.c
+++ b/src/version.c
@@ -705,6 +705,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 10,
+/**/
9,
/**/
8,
diff --git a/src/vim.h b/src/vim.h
index 3aa04f5548..e41dfef01b 100644
--- a/src/vim.h
+++ b/src/vim.h
@@ -841,6 +841,7 @@ extern int (*dyn_libintl_wputenv)(const wchar_t *envstring);
#define EXPAND_SETTING_SUBTRACT 55
#define EXPAND_ARGOPT 56
#define EXPAND_TERMINALOPT 57
+#define EXPAND_KEYMAP 58
// Values for exmode_active (0 is no exmode)
#define EXMODE_NORMAL 1