lua: make vim.inspect available early so it can be used for path debugging

This commit is contained in:
Björn Linse
2020-11-04 10:41:22 +01:00
parent aaaad0f593
commit 1b0e4a5906
6 changed files with 119 additions and 103 deletions

View File

@@ -488,13 +488,29 @@ static int nlua_state_init(lua_State *const lstate) FUNC_ATTR_NONNULL_ALL
{
const char *code = (char *)&shared_module[0];
if (luaL_loadbuffer(lstate, code, strlen(code), "@shared.lua")
if (luaL_loadbuffer(lstate, code, strlen(code), "@vim/shared.lua")
|| lua_pcall(lstate, 0, 0, 0)) {
nlua_error(lstate, _("E5106: Error while creating shared module: %.*s"));
return 1;
}
}
{
lua_getglobal(lstate, "package"); // [package]
lua_getfield(lstate, -1, "loaded"); // [package, loaded]
const char *code = (char *)&inspect_module[0];
if (luaL_loadbuffer(lstate, code, strlen(code), "@vim/inspect.lua")
|| lua_pcall(lstate, 0, 1, 0)) {
nlua_error(lstate, _("E5106: Error while creating inspect module: %.*s"));
return 1;
}
// [package, loaded, inspect]
lua_setfield(lstate, -2, "vim.inspect"); // [package, loaded]
lua_pop(lstate, 2); // []
}
{
const char *code = (char *)&vim_module[0];
if (luaL_loadbuffer(lstate, code, strlen(code), "@vim.lua")