lua: metatable for empty dict value

This commit is contained in:
Björn Linse
2019-11-27 20:45:41 +01:00
parent a251b588ac
commit ea4127e9a7
8 changed files with 101 additions and 4 deletions

View File

@@ -324,6 +324,13 @@ static int nlua_state_init(lua_State *const lstate) FUNC_ATTR_NONNULL_ALL
nlua_nil_ref = nlua_ref(lstate, -1);
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_setfield(lstate, -2, "_empty_dict_mt");
// internal vim._treesitter... API
nlua_add_treesitter(lstate);
@@ -665,6 +672,12 @@ static int nlua_nil_tostring(lua_State *lstate)
return 1;
}
static int nlua_empty_dict_tostring(lua_State *lstate)
{
lua_pushstring(lstate, "vim.empty_dict()");
return 1;
}
#ifdef WIN32
/// os.getenv: override os.getenv to maintain coherency. #9681