aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api/vim.c
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2017-05-09 08:55:04 +0200
committerBjörn Linse <bjorn.linse@gmail.com>2017-05-13 15:03:42 +0200
commitf424189093ab23fb727a996d317ff19d4d3f0b63 (patch)
tree582a5a9a74a8a4f32c4fc0a9dea165efc3490089 /src/nvim/api/vim.c
parent12fb634fe691a6ccfbd9bc7b44510c782af6c70a (diff)
downloadrneovim-f424189093ab23fb727a996d317ff19d4d3f0b63.tar.gz
rneovim-f424189093ab23fb727a996d317ff19d4d3f0b63.tar.bz2
rneovim-f424189093ab23fb727a996d317ff19d4d3f0b63.zip
api: execute lua directly from the remote api
Diffstat (limited to 'src/nvim/api/vim.c')
-rw-r--r--src/nvim/api/vim.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c
index d0bb840b8d..1fedaf30ef 100644
--- a/src/nvim/api/vim.c
+++ b/src/nvim/api/vim.c
@@ -15,6 +15,7 @@
#include "nvim/api/private/defs.h"
#include "nvim/api/buffer.h"
#include "nvim/msgpack_rpc/channel.h"
+#include "nvim/lua/executor.h"
#include "nvim/vim.h"
#include "nvim/buffer.h"
#include "nvim/file_search.h"
@@ -254,6 +255,25 @@ free_vim_args:
return rv;
}
+/// Execute lua code. Parameters might be passed, they are available inside
+/// the chunk as `...`. The chunk can return a value.
+///
+/// To evaluate an expression, it must be prefixed with "return ". For
+/// instance, to call a lua function with arguments sent in and get its
+/// return value back, use the code "return my_function(...)".
+///
+/// @param code lua code to execute
+/// @param args Arguments to the code
+/// @param[out] err Details of an error encountered while parsing
+/// or executing the lua code.
+///
+/// @return Return value of lua code if present or NIL.
+Object nvim_execute_lua(String code, Array args, Error *err)
+ FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY
+{
+ return executor_exec_lua_api(code, args, err);
+}
+
/// Calculates the number of display cells occupied by `text`.
/// <Tab> counts as one cell.
///