mirror of
https://github.com/neovim/neovim.git
synced 2025-09-08 12:28:18 +00:00
executor: use new nlua_ name pattern
This commit is contained in:
@@ -927,7 +927,7 @@ void nlua_typval_eval(const String str, typval_T *const arg,
|
|||||||
memcpy(lcmd + sizeof(EVALHEADER) - 1, str.data, str.size);
|
memcpy(lcmd + sizeof(EVALHEADER) - 1, str.data, str.size);
|
||||||
lcmd[lcmd_len - 1] = ')';
|
lcmd[lcmd_len - 1] = ')';
|
||||||
#undef EVALHEADER
|
#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) {
|
if (lcmd != (char *)IObuff) {
|
||||||
xfree(lcmd);
|
xfree(lcmd);
|
||||||
@@ -954,16 +954,16 @@ void nlua_typval_call(const char *str, size_t len, typval_T *const args,
|
|||||||
#undef CALLHEADER
|
#undef CALLHEADER
|
||||||
#undef CALLSUFFIX
|
#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) {
|
if (lcmd != (char *)IObuff) {
|
||||||
xfree(lcmd);
|
xfree(lcmd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void typval_exec_lua(const char *lcmd, size_t lcmd_len, const char *name,
|
static void nlua_typval_exec(const char *lcmd, size_t lcmd_len,
|
||||||
typval_T *const args, int argcount, bool special,
|
const char *name, typval_T *const args,
|
||||||
typval_T *ret_tv)
|
int argcount, bool special, typval_T *ret_tv)
|
||||||
{
|
{
|
||||||
if (check_secure()) {
|
if (check_secure()) {
|
||||||
if (ret_tv) {
|
if (ret_tv) {
|
||||||
@@ -1140,7 +1140,7 @@ void ex_lua(exarg_T *const eap)
|
|||||||
xfree(code);
|
xfree(code);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
typval_exec_lua(code, len, ":lua", NULL, 0, false, NULL);
|
nlua_typval_exec(code, len, ":lua", NULL, 0, false, NULL);
|
||||||
|
|
||||||
xfree(code);
|
xfree(code);
|
||||||
}
|
}
|
||||||
@@ -1231,24 +1231,20 @@ void ex_luado(exarg_T *const eap)
|
|||||||
void ex_luafile(exarg_T *const eap)
|
void ex_luafile(exarg_T *const eap)
|
||||||
FUNC_ATTR_NONNULL_ALL
|
FUNC_ATTR_NONNULL_ALL
|
||||||
{
|
{
|
||||||
lua_State *const lstate = nlua_enter();
|
nlua_exec_file((const char *)eap->arg);
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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();
|
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"));
|
nlua_error(lstate, _("E5112: Error while creating lua chunk: %.*s"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@@ -1778,7 +1778,7 @@ static bool do_user_initialization(void)
|
|||||||
|
|
||||||
char_u *init_lua_path = (char_u *)stdpaths_user_conf_subpath("init.lua");
|
char_u *init_lua_path = (char_u *)stdpaths_user_conf_subpath("init.lua");
|
||||||
if (os_path_exists(init_lua_path)
|
if (os_path_exists(init_lua_path)
|
||||||
&& load_init_lua((const char *)init_lua_path)) {
|
&& nlua_exec_file((const char *)init_lua_path)) {
|
||||||
os_setenv("MYVIMRC", (const char *)init_lua_path, 1);
|
os_setenv("MYVIMRC", (const char *)init_lua_path, 1);
|
||||||
char_u *vimrc_path = (char_u *)stdpaths_user_conf_subpath("init.vim");
|
char_u *vimrc_path = (char_u *)stdpaths_user_conf_subpath("init.vim");
|
||||||
|
|
||||||
@@ -1852,7 +1852,7 @@ static void source_startup_scripts(const mparm_T *const parmp)
|
|||||||
// Do nothing.
|
// Do nothing.
|
||||||
} else {
|
} else {
|
||||||
if (path_with_extension(parmp->use_vimrc, "lua")) {
|
if (path_with_extension(parmp->use_vimrc, "lua")) {
|
||||||
load_init_lua(parmp->use_vimrc);
|
nlua_exec_file(parmp->use_vimrc);
|
||||||
} else {
|
} else {
|
||||||
if (do_source((char_u *)parmp->use_vimrc, false, DOSO_NONE) != OK) {
|
if (do_source((char_u *)parmp->use_vimrc, false, DOSO_NONE) != OK) {
|
||||||
EMSG2(_("E282: Cannot read from \"%s\""), parmp->use_vimrc);
|
EMSG2(_("E282: Cannot read from \"%s\""), parmp->use_vimrc);
|
||||||
|
Reference in New Issue
Block a user