diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2020-09-17 14:36:55 +0200 |
---|---|---|
committer | Björn Linse <bjorn.linse@gmail.com> | 2020-12-01 10:51:31 +0100 |
commit | eb387ae53009b4da93fbbb3423e5ef01023dc32a (patch) | |
tree | b1f24edc66ab0b003e1d1843263180f84b4e56c5 /src/nvim/lua/executor.c | |
parent | c65d3fd67b0fb2688c444e43e54fb9a7d26f5f3d (diff) | |
download | rneovim-eb387ae53009b4da93fbbb3423e5ef01023dc32a.tar.gz rneovim-eb387ae53009b4da93fbbb3423e5ef01023dc32a.tar.bz2 rneovim-eb387ae53009b4da93fbbb3423e5ef01023dc32a.zip |
executor: use new nlua_ name pattern
Diffstat (limited to 'src/nvim/lua/executor.c')
-rw-r--r-- | src/nvim/lua/executor.c | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c index 97f6d5bd31..344a2387d6 100644 --- a/src/nvim/lua/executor.c +++ b/src/nvim/lua/executor.c @@ -927,7 +927,7 @@ void nlua_typval_eval(const String str, typval_T *const arg, memcpy(lcmd + sizeof(EVALHEADER) - 1, str.data, str.size); lcmd[lcmd_len - 1] = ')'; #undef EVALHEADER - typval_exec_lua(lcmd, lcmd_len, "luaeval()", arg, 1, true, ret_tv); + nlua_typval_exec(lcmd, lcmd_len, "luaeval()", arg, 1, true, ret_tv); if (lcmd != (char *)IObuff) { xfree(lcmd); @@ -954,16 +954,16 @@ void nlua_typval_call(const char *str, size_t len, typval_T *const args, #undef CALLHEADER #undef CALLSUFFIX - typval_exec_lua(lcmd, lcmd_len, "v:lua", args, argcount, false, ret_tv); + nlua_typval_exec(lcmd, lcmd_len, "v:lua", args, argcount, false, ret_tv); if (lcmd != (char *)IObuff) { xfree(lcmd); } } -static void typval_exec_lua(const char *lcmd, size_t lcmd_len, const char *name, - typval_T *const args, int argcount, bool special, - typval_T *ret_tv) +static void nlua_typval_exec(const char *lcmd, size_t lcmd_len, + const char *name, typval_T *const args, + int argcount, bool special, typval_T *ret_tv) { if (check_secure()) { if (ret_tv) { @@ -1140,7 +1140,7 @@ void ex_lua(exarg_T *const eap) xfree(code); return; } - typval_exec_lua(code, len, ":lua", NULL, 0, false, NULL); + nlua_typval_exec(code, len, ":lua", NULL, 0, false, NULL); xfree(code); } @@ -1231,24 +1231,20 @@ void ex_luado(exarg_T *const eap) void ex_luafile(exarg_T *const eap) FUNC_ATTR_NONNULL_ALL { - lua_State *const lstate = nlua_enter(); - - if (luaL_loadfile(lstate, (const char *)eap->arg)) { - nlua_error(lstate, _("E5112: Error while creating lua chunk: %.*s")); - return; - } - - if (lua_pcall(lstate, 0, 0, 0)) { - nlua_error(lstate, _("E5113: Error while calling lua chunk: %.*s")); - return; - } + nlua_exec_file((const char *)eap->arg); } -bool load_init_lua(const char *script_path) +/// execute lua code from a file. +/// +/// @param path path of the file +/// +/// @return true if everything ok, false if there was an error (echoed) +bool nlua_exec_file(const char *path) + FUNC_ATTR_NONNULL_ALL { lua_State *const lstate = nlua_enter(); - if (luaL_loadfile(lstate, script_path)) { + if (luaL_loadfile(lstate, path)) { nlua_error(lstate, _("E5112: Error while creating lua chunk: %.*s")); return false; } |