mirror of
https://github.com/neovim/neovim.git
synced 2025-09-29 06:28:35 +00:00
feat(lua): make vim.mpack support vim.NIL and vim.empty_dict()
This commit is contained in:
@@ -507,8 +507,18 @@ 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
|
||||
lua_createtable(lstate, 0, 0);
|
||||
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);
|
||||
@@ -523,14 +533,6 @@ static int nlua_state_init(lua_State *const lstate) FUNC_ATTR_NONNULL_ALL
|
||||
lua_setfield(lstate, -2, "mpack");
|
||||
lua_pop(lstate, 3);
|
||||
|
||||
|
||||
// vim._empty_dict_mt
|
||||
lua_createtable(lstate, 0, 0);
|
||||
lua_pushcfunction(lstate, &nlua_empty_dict_tostring);
|
||||
lua_setfield(lstate, -2, "__tostring");
|
||||
nlua_empty_dict_ref = nlua_ref(lstate, -1);
|
||||
lua_setfield(lstate, -2, "_empty_dict_mt");
|
||||
|
||||
// internal vim._treesitter... API
|
||||
nlua_add_treesitter(lstate);
|
||||
|
||||
|
Reference in New Issue
Block a user