aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/lua/executor.c
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2021-08-30 18:09:53 +0200
committerGitHub <noreply@github.com>2021-08-30 18:09:53 +0200
commit9695691ee4868ea9fdd8a6d84b9980fc22c77aa3 (patch)
tree9c2f0924ab3a8c8e4930c222e5b7cefeb995e955 /src/nvim/lua/executor.c
parentc52ec8f9eb397da3440dcd821c41d5687b46ec16 (diff)
parent6f2d0ea31149a25a5d834dce0ea1fe25d5f95a7c (diff)
downloadrneovim-9695691ee4868ea9fdd8a6d84b9980fc22c77aa3.tar.gz
rneovim-9695691ee4868ea9fdd8a6d84b9980fc22c77aa3.tar.bz2
rneovim-9695691ee4868ea9fdd8a6d84b9980fc22c77aa3.zip
Merge pull request #15526 from bfredl/f_meta
fix(lua): make core vim module not dependent on $VIMRUNTIME modules
Diffstat (limited to 'src/nvim/lua/executor.c')
-rw-r--r--src/nvim/lua/executor.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c
index b00c4282be..5cd9894f9d 100644
--- a/src/nvim/lua/executor.c
+++ b/src/nvim/lua/executor.c
@@ -544,8 +544,17 @@ static int nlua_state_init(lua_State *const lstate) FUNC_ATTR_NONNULL_ALL
return 1;
}
// [package, loaded, inspect]
-
lua_setfield(lstate, -2, "vim.inspect"); // [package, loaded]
+
+ code = (char *)&lua_F_module[0];
+ if (luaL_loadbuffer(lstate, code, strlen(code), "@vim/F.lua")
+ || lua_pcall(lstate, 0, 1, 0)) {
+ nlua_error(lstate, _("E5106: Error while creating vim.F module: %.*s"));
+ return 1;
+ }
+ // [package, loaded, module]
+ lua_setfield(lstate, -2, "vim.F"); // [package, loaded]
+
lua_pop(lstate, 2); // []
}
@@ -558,6 +567,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 *)&lua_meta_module[0];
+ if (luaL_loadbuffer(lstate, code, strlen(code), "@vim/_meta.lua")
+ || lua_pcall(lstate, 0, 1, 0)) {
+ nlua_error(lstate, _("E5106: Error while creating vim._meta module: %.*s"));
+ return 1;
+ }
+ // [package, loaded, module]
+ lua_setfield(lstate, -2, "vim._meta"); // [package, loaded]
+
+ lua_pop(lstate, 2); // []
+ }
+
return 0;
}