diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2021-09-09 18:47:03 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-09 18:47:03 +0200 |
commit | d80aac3b2a3ce4b25d4f12ff64b8c947eaf75826 (patch) | |
tree | b10dcaea8ee55a9f27b528360eb0dab50e165121 /src/nvim/lua/executor.c | |
parent | 13748512f6d6dfb5895c2233d2e07480e00eb753 (diff) | |
parent | ad8eda3f5b7db424de912ac748bce6b02e43f64f (diff) | |
download | rneovim-d80aac3b2a3ce4b25d4f12ff64b8c947eaf75826.tar.gz rneovim-d80aac3b2a3ce4b25d4f12ff64b8c947eaf75826.tar.bz2 rneovim-d80aac3b2a3ce4b25d4f12ff64b8c947eaf75826.zip |
Merge pull request #15566 from bfredl/mpack
libs: vendor libmpack and libmpack-lua
Diffstat (limited to 'src/nvim/lua/executor.c')
-rw-r--r-- | src/nvim/lua/executor.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c index a8b10f86f5..d071203db1 100644 --- a/src/nvim/lua/executor.c +++ b/src/nvim/lua/executor.c @@ -33,6 +33,7 @@ #include "nvim/eval/userfunc.h" #include "nvim/event/time.h" #include "nvim/event/loop.h" +#include "mpack/lmpack.h" #include "nvim/os/os.h" @@ -506,6 +507,8 @@ static int nlua_state_init(lua_State *const lstate) FUNC_ATTR_NONNULL_ALL lua_setfield(lstate, -2, "__tostring"); lua_setmetatable(lstate, -2); nlua_nil_ref = nlua_ref(lstate, -1); + lua_pushvalue(lstate, -1); + lua_setfield(lstate, LUA_REGISTRYINDEX, "mpack.NIL"); lua_setfield(lstate, -2, "NIL"); // vim._empty_dict_mt @@ -513,8 +516,23 @@ static int nlua_state_init(lua_State *const lstate) FUNC_ATTR_NONNULL_ALL lua_pushcfunction(lstate, &nlua_empty_dict_tostring); lua_setfield(lstate, -2, "__tostring"); nlua_empty_dict_ref = nlua_ref(lstate, -1); + lua_pushvalue(lstate, -1); + lua_setfield(lstate, LUA_REGISTRYINDEX, "mpack.empty_dict"); lua_setfield(lstate, -2, "_empty_dict_mt"); + // vim.mpack + luaopen_mpack(lstate); + lua_pushvalue(lstate, -1); + lua_setfield(lstate, -3, "mpack"); + + // package.loaded.mpack = vim.mpack + // otherwise luv will be reinitialized when require'mpack' + lua_getglobal(lstate, "package"); + lua_getfield(lstate, -1, "loaded"); + lua_pushvalue(lstate, -3); + lua_setfield(lstate, -2, "mpack"); + lua_pop(lstate, 3); + // internal vim._treesitter... API nlua_add_treesitter(lstate); |