diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2017-05-13 15:06:41 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-13 15:06:41 +0200 |
commit | 244a1f97db6da0441607754dab9ae11096bffd9e (patch) | |
tree | 5ba7ce5425f2bfce681b3bcbe318363bf872e450 /src/nvim/api/vim.c | |
parent | ac47f8a50691e6ce99c54712e5c984db8b1f079e (diff) | |
parent | f424189093ab23fb727a996d317ff19d4d3f0b63 (diff) | |
download | rneovim-244a1f97db6da0441607754dab9ae11096bffd9e.tar.gz rneovim-244a1f97db6da0441607754dab9ae11096bffd9e.tar.bz2 rneovim-244a1f97db6da0441607754dab9ae11096bffd9e.zip |
Merge pull request #6704 from bfredl/luaexec
execute lua directly from the remote API
Diffstat (limited to 'src/nvim/api/vim.c')
-rw-r--r-- | src/nvim/api/vim.c | 20 |
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. /// |