mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
make vim.loop == require'luv'
This avoids initializing libluv a second time if a plugin invokes require'luv'. It is probably not an issue, but better to be safe.
This commit is contained in:
parent
d33aaa0f5f
commit
99f24dfbed
@ -228,7 +228,16 @@ static int nlua_state_init(lua_State *const lstate) FUNC_ATTR_NONNULL_ALL
|
||||
luv_set_loop(lstate, &main_loop.uv);
|
||||
luv_set_callback(lstate, nlua_luv_cfpcall);
|
||||
luaopen_luv(lstate);
|
||||
lua_setfield(lstate, -2, "loop");
|
||||
lua_pushvalue(lstate, -1);
|
||||
lua_setfield(lstate, -3, "loop");
|
||||
|
||||
// package.loaded.luv = vim.loop
|
||||
// otherwise luv will be reinitialized when require'luv'
|
||||
lua_getglobal(lstate, "package");
|
||||
lua_getfield(lstate, -1, "loaded");
|
||||
lua_pushvalue(lstate, -3);
|
||||
lua_setfield(lstate, -2, "luv");
|
||||
lua_pop(lstate, 3);
|
||||
|
||||
lua_setglobal(lstate, "vim");
|
||||
return 0;
|
||||
|
@ -142,4 +142,8 @@ describe('vim.loop', function()
|
||||
]])
|
||||
eq({blocking=false, mode='n'}, exec_lua("return _G.mode"))
|
||||
end)
|
||||
|
||||
it("is equal to require('luv')", function()
|
||||
eq(true, exec_lua("return vim.loop == require('luv')"))
|
||||
end)
|
||||
end)
|
||||
|
Loading…
Reference in New Issue
Block a user