aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/lua/executor.c
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2020-11-04 10:41:22 +0100
committerBjörn Linse <bjorn.linse@gmail.com>2020-11-05 14:46:41 +0100
commit1b0e4a5906d3c9fcb4290f943c7b048b3c35353b (patch)
tree9a9e48bae3de8a7a68c3fb911fd6f3f6f3ec7948 /src/nvim/lua/executor.c
parentaaaad0f5934460dfaf7ef7a29dcf38060c641b43 (diff)
downloadrneovim-1b0e4a5906d3c9fcb4290f943c7b048b3c35353b.tar.gz
rneovim-1b0e4a5906d3c9fcb4290f943c7b048b3c35353b.tar.bz2
rneovim-1b0e4a5906d3c9fcb4290f943c7b048b3c35353b.zip
lua: make vim.inspect available early so it can be used for path debugging
Diffstat (limited to 'src/nvim/lua/executor.c')
-rw-r--r--src/nvim/lua/executor.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c
index a095f298f2..40f508d225 100644
--- a/src/nvim/lua/executor.c
+++ b/src/nvim/lua/executor.c
@@ -488,7 +488,7 @@ 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;
@@ -496,6 +496,22 @@ static int nlua_state_init(lua_State *const lstate) FUNC_ATTR_NONNULL_ALL
}
{
+ 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")
|| lua_pcall(lstate, 0, 0, 0)) {