From c83926cd0aa5720e88e84fa3fae3c0e689cca3ef Mon Sep 17 00:00:00 2001 From: George Zhao Date: Mon, 10 Jun 2019 20:13:18 +0800 Subject: lua: introduce vim.loop (expose libuv event-loop) #10123 Co-authored-by: Andrey Popp <8mayday@gmail.com> closes #9546 closes #10084 --- src/nvim/CMakeLists.txt | 1 + src/nvim/lua/executor.c | 7 +++++++ 2 files changed, 8 insertions(+) (limited to 'src') diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt index 8abc43c2aa..77c5bf59e4 100644 --- a/src/nvim/CMakeLists.txt +++ b/src/nvim/CMakeLists.txt @@ -383,6 +383,7 @@ endif() # Put these last on the link line, since multiple things may depend on them. list(APPEND NVIM_LINK_LIBRARIES + ${LIBLUV_LIBRARIES} ${LIBUV_LIBRARIES} ${MSGPACK_LIBRARIES} ${LIBVTERM_LIBRARIES} diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c index df08a9dd87..8cb282356a 100644 --- a/src/nvim/lua/executor.c +++ b/src/nvim/lua/executor.c @@ -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; } -- cgit