aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/lua/executor.c
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2020-11-05 18:43:00 +0100
committerGitHub <noreply@github.com>2020-11-05 18:43:00 +0100
commitd17e508796be60eefe4a597df62de1fd9e7e1725 (patch)
tree31079372c1a12846700955af1dd0dcddf3449a6a /src/nvim/lua/executor.c
parent0227091fb91a5ece94d6e95778912d02b23f77bb (diff)
parent1b0e4a5906d3c9fcb4290f943c7b048b3c35353b (diff)
downloadrneovim-d17e508796be60eefe4a597df62de1fd9e7e1725.tar.gz
rneovim-d17e508796be60eefe4a597df62de1fd9e7e1725.tar.bz2
rneovim-d17e508796be60eefe4a597df62de1fd9e7e1725.zip
Merge pull request #13227 from bfredl/earlyinspect
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)) {