From 767cd8b17b71f78bdd4c2e0dd8d3f4f0f1551381 Mon Sep 17 00:00:00 2001 From: dm1try Date: Sun, 3 May 2020 23:49:11 +0300 Subject: startup: add init.lua as an alternative user config, fixes #7895 --- src/nvim/lua/executor.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/nvim/lua') diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c index 0a3c30134b..97f6d5bd31 100644 --- a/src/nvim/lua/executor.c +++ b/src/nvim/lua/executor.c @@ -1244,6 +1244,23 @@ void ex_luafile(exarg_T *const eap) } } +bool load_init_lua(const char *script_path) +{ + lua_State *const lstate = nlua_enter(); + + if (luaL_loadfile(lstate, script_path)) { + nlua_error(lstate, _("E5112: Error while creating lua chunk: %.*s")); + return false; + } + + if (lua_pcall(lstate, 0, 0, 0)) { + nlua_error(lstate, _("E5113: Error while calling lua chunk: %.*s")); + return false; + } + + return true; +} + static void nlua_add_treesitter(lua_State *const lstate) FUNC_ATTR_NONNULL_ALL { tslua_init(lstate); -- cgit