diff options
-rw-r--r-- | runtime/doc/builtin.txt | 1 | ||||
-rw-r--r-- | runtime/doc/map.txt | 1 | ||||
-rw-r--r-- | runtime/lua/vim/_meta/vimfn.lua | 1 | ||||
-rw-r--r-- | src/nvim/cmdexpand.c | 6 | ||||
-rw-r--r-- | src/nvim/cmdexpand_defs.h | 1 | ||||
-rw-r--r-- | src/nvim/eval.lua | 1 | ||||
-rw-r--r-- | src/nvim/option.c | 4 | ||||
-rw-r--r-- | src/nvim/usercmd.c | 1 | ||||
-rw-r--r-- | test/old/testdir/test_cmdline.vim | 7 | ||||
-rw-r--r-- | test/old/testdir/test_options.vim | 8 |
10 files changed, 31 insertions, 0 deletions
diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt index 98201c0eed..5f89082b6f 100644 --- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -2372,6 +2372,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 diff --git a/runtime/doc/map.txt b/runtime/doc/map.txt index 6f61259af0..d1f61dce85 100644 --- a/runtime/doc/map.txt +++ b/runtime/doc/map.txt @@ -1389,6 +1389,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=lua Lua expression |:lua| -complete=mapclear buffer argument diff --git a/runtime/lua/vim/_meta/vimfn.lua b/runtime/lua/vim/_meta/vimfn.lua index 02e794ce10..a763be93b9 100644 --- a/runtime/lua/vim/_meta/vimfn.lua +++ b/runtime/lua/vim/_meta/vimfn.lua @@ -2889,6 +2889,7 @@ function vim.fn.getcmdwintype() end --- 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 diff --git a/src/nvim/cmdexpand.c b/src/nvim/cmdexpand.c index 4dcdc06328..2d66526f33 100644 --- a/src/nvim/cmdexpand.c +++ b/src/nvim/cmdexpand.c @@ -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); } diff --git a/src/nvim/cmdexpand_defs.h b/src/nvim/cmdexpand_defs.h index 0bd977daca..923ba62099 100644 --- a/src/nvim/cmdexpand_defs.h +++ b/src/nvim/cmdexpand_defs.h @@ -105,6 +105,7 @@ enum { EXPAND_STRING_SETTING, EXPAND_SETTING_SUBTRACT, EXPAND_ARGOPT, + EXPAND_KEYMAP, EXPAND_CHECKHEALTH, EXPAND_LUA, }; diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index 342650f0e3..322ab829a0 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -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 diff --git a/src/nvim/option.c b/src/nvim/option.c index 7f6623017e..495a6819f9 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -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. diff --git a/src/nvim/usercmd.c b/src/nvim/usercmd.c index 30f31d5bd9..39f80878c9 100644 --- a/src/nvim/usercmd.c +++ b/src/nvim/usercmd.c @@ -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 diff --git a/test/old/testdir/test_cmdline.vim b/test/old/testdir/test_cmdline.vim index 3f13218c5b..edc1d7439a 100644 --- a/test/old/testdir/test_cmdline.vim +++ b/test/old/testdir/test_cmdline.vim @@ -532,6 +532,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/test/old/testdir/test_options.vim b/test/old/testdir/test_options.vim index 2aa7d3ab65..52b675f54d 100644 --- a/test/old/testdir/test_options.vim +++ b/test/old/testdir/test_options.vim @@ -439,6 +439,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 |