diff options
author | ZyX <kp-pav@yandex.ru> | 2017-01-29 02:41:37 +0300 |
---|---|---|
committer | ZyX <kp-pav@yandex.ru> | 2017-03-27 00:12:23 +0300 |
commit | 872a909150506828f72a63636e1cfd6b72f1b306 (patch) | |
tree | 36f8399ec115692596630b1fdc24cd35ead88ae4 | |
parent | 62fde319360e27a86c0deba0053ff230f80ca772 (diff) | |
download | rneovim-872a909150506828f72a63636e1cfd6b72f1b306.tar.gz rneovim-872a909150506828f72a63636e1cfd6b72f1b306.tar.bz2 rneovim-872a909150506828f72a63636e1cfd6b72f1b306.zip |
executor: Add :lua command
Does not work currently.
-rw-r--r-- | src/nvim/ex_cmds.lua | 2 | ||||
-rw-r--r-- | src/nvim/ex_docmd.c | 1 | ||||
-rw-r--r-- | src/nvim/viml/executor/executor.c | 19 |
3 files changed, 19 insertions, 3 deletions
diff --git a/src/nvim/ex_cmds.lua b/src/nvim/ex_cmds.lua index 92f0669422..b34975f00e 100644 --- a/src/nvim/ex_cmds.lua +++ b/src/nvim/ex_cmds.lua @@ -1542,7 +1542,7 @@ return { command='lua', flags=bit.bor(RANGE, EXTRA, NEEDARG, CMDWIN), addr_type=ADDR_LINES, - func='ex_script_ni', + func='ex_lua', }, { command='luado', diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 486baaad47..aa43b71a0d 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -67,6 +67,7 @@ #include "nvim/event/rstream.h" #include "nvim/event/wstream.h" #include "nvim/shada.h" +#include "nvim/viml/executor/executor.h" static int quitmore = 0; static int ex_pressedreturn = FALSE; diff --git a/src/nvim/viml/executor/executor.c b/src/nvim/viml/executor/executor.c index acc375881c..8da218270a 100644 --- a/src/nvim/viml/executor/executor.c +++ b/src/nvim/viml/executor/executor.c @@ -7,8 +7,10 @@ #include "nvim/garray.h" #include "nvim/func_attr.h" #include "nvim/api/private/defs.h" +#include "nvim/api/private/helpers.h" #include "nvim/api/vim.h" #include "nvim/vim.h" +#include "nvim/ex_getln.h" #include "nvim/message.h" #include "nvim/viml/executor/executor.h" @@ -171,8 +173,6 @@ static lua_State *global_lstate = NULL; /// Execute lua string /// -/// Used for :lua. -/// /// @param[in] str String to execute. /// @param[out] ret_tv Location where result will be saved. /// @@ -267,3 +267,18 @@ void executor_eval_lua(const String str, typval_T *const arg, NLUA_CALL_C_FUNCTION_3(global_lstate, nlua_eval_lua_string, 0, (void *)&str, arg, ret_tv); } + +/// Run lua string +/// +/// Used for :lua. +/// +/// @param eap VimL command being run. +void ex_lua(exarg_T *const eap) + FUNC_ATTR_NONNULL_ALL +{ + char *const code = (char *)script_get(eap, eap->arg); + typval_T tv = { .v_type = VAR_UNKNOWN }; + executor_exec_lua(cstr_as_string(code), &tv); + clear_tv(&tv); + xfree(code); +} |