aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api/vim.c
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2019-01-09 11:43:19 +0100
committerGitHub <noreply@github.com>2019-01-09 11:43:19 +0100
commit8510d5ff865f41e5025943a1c804d2d1e65f0663 (patch)
treeacd6ee76bb46fd5ebcd3c74cf9550acb07e8ceae /src/nvim/api/vim.c
parenta4076e5dcf6624a958a1bda64a435949358f79b0 (diff)
parentae218c108f31a61b958bdbdf6bbb098ae5b71314 (diff)
downloadrneovim-8510d5ff865f41e5025943a1c804d2d1e65f0663.tar.gz
rneovim-8510d5ff865f41e5025943a1c804d2d1e65f0663.tar.bz2
rneovim-8510d5ff865f41e5025943a1c804d2d1e65f0663.zip
Merge pull request #9445 from bfredl/pum_api
API: select items in popupmenu
Diffstat (limited to 'src/nvim/api/vim.c')
-rw-r--r--src/nvim/api/vim.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c
index 796923ffcb..24e76ecf88 100644
--- a/src/nvim/api/vim.c
+++ b/src/nvim/api/vim.c
@@ -28,6 +28,7 @@
#include "nvim/screen.h"
#include "nvim/memory.h"
#include "nvim/message.h"
+#include "nvim/edit.h"
#include "nvim/eval.h"
#include "nvim/eval/typval.h"
#include "nvim/option.h"
@@ -1915,6 +1916,35 @@ Object nvim_get_proc(Integer pid, Error *err)
return rvobj;
}
+/// Selects an item in the completion popupmenu
+///
+/// When insert completion is not active, this API call is silently ignored.
+/// It is mostly useful for an external UI using |ui-popupmenu| for instance
+/// to control the popupmenu with the mouse. But it can also be used in an
+/// insert mode mapping, use <cmd> mapping |:map-cmd| to ensure the mapping
+/// doesn't end completion mode.
+///
+/// @param item Index of the item to select, starting with zero. Pass in "-1"
+/// to select no item (restore original text).
+/// @param insert Whether the selection should be inserted in the buffer.
+/// @param finish If true, completion will be finished with this item, and the
+/// popupmenu dissmissed. Implies `insert`.
+void nvim_select_popupmenu_item(Integer item, Boolean insert, Boolean finish,
+ Dictionary opts, Error *err)
+ FUNC_API_SINCE(6)
+{
+ if (opts.size > 0) {
+ api_set_error(err, kErrorTypeValidation, "opts dict isn't empty");
+ return;
+ }
+
+ if (finish) {
+ insert = true;
+ }
+
+ pum_ext_select_item((int)item, insert, finish);
+}
+
/// NB: if your UI doesn't use hlstate, this will not return hlstate first time
Array nvim__inspect_cell(Integer row, Integer col, Error *err)
{