lua: introduce vim.loop (expose libuv event-loop) #10123

Co-authored-by: Andrey Popp <8mayday@gmail.com>

closes #9546
closes #10084
This commit is contained in:
George Zhao
2019-06-10 20:13:18 +08:00
committed by Justin M. Keyes
parent 3e58e60568
commit c83926cd0a
8 changed files with 129 additions and 6 deletions

View File

@@ -31,6 +31,8 @@
#include "nvim/lua/executor.h"
#include "nvim/lua/converter.h"
#include "luv/luv.h"
typedef struct {
Error err;
String lua_err_str;
@@ -176,6 +178,11 @@ static int nlua_state_init(lua_State *const lstate) FUNC_ATTR_NONNULL_ALL
lua_pushcfunction(lstate, &nlua_schedule);
lua_setfield(lstate, -2, "schedule");
// vim.loop
luv_set_loop(lstate, &main_loop.uv);
luaopen_luv(lstate);
lua_setfield(lstate, -2, "loop");
lua_setglobal(lstate, "vim");
return 0;
}