]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.0010: Keymap completion is not available v9.1.0010
authorDoug Kearns <dougkearns@gmail.com>
Thu, 4 Jan 2024 21:37:44 +0000 (22:37 +0100)
committerChristian Brabandt <cb@256bit.org>
Thu, 4 Jan 2024 21:37:44 +0000 (22:37 +0100)
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>
runtime/doc/builtin.txt
runtime/doc/map.txt
src/cmdexpand.c
src/option.c
src/testdir/test_cmdline.vim
src/testdir/test_options.vim
src/usercmd.c
src/version.c
src/vim.h

index 8f79d2001dfbc872f72c764cc346f5ce3cff97fe..94fcdf70c60e683870ec3998d72d20769dd8b453 100644 (file)
@@ -1,4 +1,4 @@
-*builtin.txt*  For Vim version 9.1.  Last change: 2023 Dec 24
+*builtin.txt*  For Vim version 9.1.  Last change: 2024 Jan 04
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -3570,6 +3570,7 @@ getcompletion({pat}, {type} [, {filtered}])               *getcompletion()*
                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
index d458aa661a1dd93a279e01995b226686ef4ee4c1..7d4d53048daeca18289cdfc022c8a186d0ccc13c 100644 (file)
@@ -1,4 +1,4 @@
-*map.txt*       For Vim version 9.1.  Last change: 2023 December 31
+*map.txt*       For Vim version 9.1.  Last change: 2024 Jan 04
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -1631,6 +1631,7 @@ completion can be enabled:
        -complete=help          help subjects
        -complete=highlight     highlight groups
        -complete=history       :history suboptions
+       -complete=keymap        keyboard mappings
        -complete=locale        locale names (as output of locale -a)
        -complete=mapclear      buffer argument
        -complete=mapping       mapping name
index 8bccaa3bb0cedb955615a3b529b03c7beb4cff85..1008bf97e5dd731d86741d6d322033ecc0fe6a07 100644 (file)
@@ -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);
index 7cac89e5cfb0a3e3e70749fe895a6752193458cc..2372c1aa9b1197e1c1bb2a083916512a4c41834b 100644 (file)
@@ -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.
index 33ff606424f1451f094b22d74f6d5b204d1ecc23..455471267068f85f799713a434e25f1b9575b8b2 100644 (file)
@@ -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')
index 8c336abf7d53a57cbec094ea6ff8dfff3d43bf5f..37dc20187eece0e23e81060e92c706552a1951ed 100644 (file)
@@ -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
index 04b341933ac3e843895e7d2d6107c4a114926899..e2c0114ca3ca8ce585f39b90e311e65a64dd4baa 100644 (file)
@@ -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
index 2e7f2871ea5cc5c64d5628d1ba6344ecbb6d7964..c31fbf63587a61c15af0d8c6cbb3e1fa9773b84b 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    10,
 /**/
     9,
 /**/
index 3aa04f5548f0d8f8b963a43cec95898b7199368a..e41dfef01bae8a2d1abd7dcbe37c8965ce955012 100644 (file)
--- 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