aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/doc/ui.txt19
-rw-r--r--src/nvim/api/ui_events.in.h7
-rw-r--r--src/nvim/ex_getln.c27
-rw-r--r--test/functional/ui/wildmode_spec.lua99
4 files changed, 147 insertions, 5 deletions
diff --git a/runtime/doc/ui.txt b/runtime/doc/ui.txt
index deac1609c0..5306126e7f 100644
--- a/runtime/doc/ui.txt
+++ b/runtime/doc/ui.txt
@@ -28,6 +28,7 @@ a dictionary with these (optional) keys:
`ext_popupmenu` Externalize the popupmenu. |ui-popupmenu|
`ext_tabline` Externalize the tabline. |ui-tabline|
`ext_cmdline` Externalize the cmdline. |ui-cmdline|
+ `ext_wildmenu` Externalize the tabline. |ui-ext-wildmenu|
Nvim will then send msgpack-rpc notifications, with the method name "redraw"
and a single argument, an array of screen update events.
@@ -287,4 +288,22 @@ Only sent if `ext_cmdline` option is set in |ui-options|
Hide the block.
==============================================================================
+Wildmenu Events *ui-wildmenu*
+
+Only sent if `ext_wildmenu` option is set in |ui-options|
+
+["wildmenu_show", items]
+ When `ext_wildmenu` is set to true, nvim will not draw the
+ wildmenu on the grid, instead when the wildmenu is to be displayed
+ this update is sent. `items` is an array of the completion items.
+
+["wildmenu_select", selected]
+ An item in the currently displayed wildmenu is selected. `selected`
+ is either a zero-based index into the array of items from the last
+ wildmenu event, or -1 if no item is selected.
+
+["wildmenu_hide"]
+ The wildmenu is hidden.
+
+==============================================================================
vim:tw=78:ts=8:noet:ft=help:norl:
diff --git a/src/nvim/api/ui_events.in.h b/src/nvim/api/ui_events.in.h
index 65357d008a..579ba1441a 100644
--- a/src/nvim/api/ui_events.in.h
+++ b/src/nvim/api/ui_events.in.h
@@ -65,6 +65,7 @@ void popupmenu_hide(void)
FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY;
void popupmenu_select(Integer selected)
FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY;
+
void tabline_update(Tabpage current, Array tabs)
FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY;
@@ -84,4 +85,10 @@ void cmdline_block_append(Array lines)
void cmdline_block_hide(void)
FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY;
+void wildmenu_show(Array content)
+ FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY;
+void wildmenu_select(Integer selected)
+ FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY;
+void wildmenu_hide(void)
+ FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY;
#endif // NVIM_API_UI_EVENTS_IN_H
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index e79476ab53..3d5e1a5476 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -534,6 +534,9 @@ static int command_line_execute(VimState *state, int key)
if (!(s->c == p_wc && KeyTyped) && s->c != p_wcm
&& s->c != Ctrl_N && s->c != Ctrl_P && s->c != Ctrl_A
&& s->c != Ctrl_L) {
+ if (ui_is_external(kUIWildmenu)) {
+ ui_call_wildmenu_hide();
+ }
if (s->xpc.xp_numfiles != -1) {
(void)ExpandOne(&s->xpc, NULL, NULL, 0, WILD_FREE);
}
@@ -3515,11 +3518,17 @@ ExpandOne (
else
findex = -1;
}
- if (p_wmnu)
- win_redr_status_matches(xp, xp->xp_numfiles, xp->xp_files,
- findex, cmd_showtail);
- if (findex == -1)
+ if (p_wmnu) {
+ if (ui_is_external(kUIWildmenu)) {
+ ui_call_wildmenu_select(findex);
+ } else {
+ win_redr_status_matches(xp, xp->xp_numfiles, xp->xp_files,
+ findex, cmd_showtail);
+ }
+ }
+ if (findex == -1) {
return vim_strsave(orig_save);
+ }
return vim_strsave(xp->xp_files[findex]);
} else
return NULL;
@@ -3876,6 +3885,15 @@ static int showmatches(expand_T *xp, int wildmenu)
showtail = cmd_showtail;
}
+ if (ui_is_external(kUIWildmenu)) {
+ Array args = ARRAY_DICT_INIT;
+ for (i = 0; i < num_files; i++) {
+ ADD(args, STRING_OBJ(cstr_to_string((char *)files_found[i])));
+ }
+ ui_call_wildmenu_show(args);
+ return EXPAND_OK;
+ }
+
if (!wildmenu) {
msg_didany = FALSE; /* lines_left will be set */
msg_start(); /* prepare for paging */
@@ -6128,4 +6146,3 @@ static void set_search_match(pos_T *t)
coladvance((colnr_T)MAXCOL);
}
}
-
diff --git a/test/functional/ui/wildmode_spec.lua b/test/functional/ui/wildmode_spec.lua
index 41a751c284..6ce76568db 100644
--- a/test/functional/ui/wildmode_spec.lua
+++ b/test/functional/ui/wildmode_spec.lua
@@ -179,3 +179,102 @@ describe('command line completion', function()
]])
end)
end)
+
+describe('External wildmenu', function()
+ local screen
+ local items, selected = nil, nil
+
+ before_each(function()
+ clear()
+ screen = Screen.new(25, 5)
+ screen:attach({rgb=true, ext_wildmenu=true})
+ screen:set_on_event_handler(function(name, data)
+ if name == "wildmenu_show" then
+ items = data[1]
+ elseif name == "wildmenu_select" then
+ selected = data[1]
+ elseif name == "wildmenu_hide" then
+ items, selected = nil, nil
+ end
+ end)
+ end)
+
+ after_each(function()
+ screen:detach()
+ end)
+
+ it('works with :sign <tab>', function()
+ local expected = {
+ 'define',
+ 'jump',
+ 'list',
+ 'place',
+ 'undefine',
+ 'unplace',
+ }
+
+ command('set wildmode=full')
+ command('set wildmenu')
+ feed(':sign <tab>')
+ screen:expect([[
+ |
+ ~ |
+ ~ |
+ ~ |
+ :sign define^ |
+ ]], nil, nil, function()
+ eq(expected, items)
+ eq(0, selected)
+ end)
+
+ feed('<tab>')
+ screen:expect([[
+ |
+ ~ |
+ ~ |
+ ~ |
+ :sign jump^ |
+ ]], nil, nil, function()
+ eq(expected, items)
+ eq(1, selected)
+ end)
+
+ feed('<left><left>')
+ screen:expect([[
+ |
+ ~ |
+ ~ |
+ ~ |
+ :sign ^ |
+ ]], nil, nil, function()
+ eq(expected, items)
+ eq(-1, selected)
+ end)
+
+ feed('<right>')
+ screen:expect([[
+ |
+ ~ |
+ ~ |
+ ~ |
+ :sign define^ |
+ ]], nil, nil, function()
+ eq(expected, items)
+ eq(0, selected)
+ end)
+
+
+
+ feed('a')
+ screen:expect([[
+ |
+ ~ |
+ ~ |
+ ~ |
+ :sign definea^ |
+ ]], nil, nil, function()
+ eq(nil, items)
+ eq(nil, selected)
+ end)
+ end)
+end)