mirror of
https://github.com/neovim/neovim.git
synced 2025-09-14 07:18:17 +00:00
feat(api): add nvim_cmd
Adds the API function `nvim_cmd` which allows executing an Ex-command through a Dictionary which can have the same values as the return value of `nvim_parse_cmd()`. This makes it much easier to do things like passing arguments with a space to commands that otherwise may not allow it, or to make commands interpret certain characters literally when they otherwise would not.
This commit is contained in:
@@ -1863,8 +1863,8 @@ void nlua_do_ucmd(ucmd_T *cmd, exarg_T *eap)
|
||||
if (cmd->uc_argt & EX_NOSPC) {
|
||||
// Commands where nargs = 1 or "?" fargs is the same as args
|
||||
lua_rawseti(lstate, -2, 1);
|
||||
} else {
|
||||
// Commands with more than one possible argument we split
|
||||
} else if (eap->args == NULL) {
|
||||
// For commands with more than one possible argument, split if argument list isn't available.
|
||||
lua_pop(lstate, 1); // Pop the reference of opts.args
|
||||
size_t length = STRLEN(eap->arg);
|
||||
size_t end = 0;
|
||||
@@ -1881,6 +1881,13 @@ void nlua_do_ucmd(ucmd_T *cmd, exarg_T *eap)
|
||||
}
|
||||
}
|
||||
xfree(buf);
|
||||
} else {
|
||||
// If argument list is available, just use it.
|
||||
lua_pop(lstate, 1);
|
||||
for (size_t i = 0; i < eap->argc; i++) {
|
||||
lua_pushlstring(lstate, eap->args[i], eap->arglens[i]);
|
||||
lua_rawseti(lstate, -2, (int)i + 1);
|
||||
}
|
||||
}
|
||||
lua_setfield(lstate, -2, "fargs");
|
||||
|
||||
|
Reference in New Issue
Block a user