aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/lua/executor.c
diff options
context:
space:
mode:
authorshadmansaleh <shadmansaleh3@gmail.com>2021-06-03 07:07:51 +0600
committershadmansaleh <shadmansaleh3@gmail.com>2021-06-11 01:01:03 +0600
commite1edc079dd0d0cb4a53e5998086568cf9d10a26a (patch)
treeeb60874111545e69847809a765c8dc6921e37aa2 /src/nvim/lua/executor.c
parent92b6b3764cf75d01bcbf04fcf598140fc01e7902 (diff)
downloadrneovim-e1edc079dd0d0cb4a53e5998086568cf9d10a26a.tar.gz
rneovim-e1edc079dd0d0cb4a53e5998086568cf9d10a26a.tar.bz2
rneovim-e1edc079dd0d0cb4a53e5998086568cf9d10a26a.zip
refactor(source): Move lua file detection to do_source
So now :source can run lua files too :) * feat: Add support for :[ranged]source for lua files
Diffstat (limited to 'src/nvim/lua/executor.c')
-rw-r--r--src/nvim/lua/executor.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c
index 0a52cc16cb..afc387ef38 100644
--- a/src/nvim/lua/executor.c
+++ b/src/nvim/lua/executor.c
@@ -1161,6 +1161,24 @@ static void nlua_typval_exec(const char *lcmd, size_t lcmd_len,
}
}
+int nlua_source_using_linegetter(LineGetter fgetline,
+ void *cookie, char *name)
+{
+ garray_T ga;
+ char_u *line = NULL;
+
+ ga_init(&ga, (int)sizeof(char_u *), 10);
+ while ((line = fgetline(0, cookie, 0, false)) != NULL) {
+ GA_APPEND(char_u *, &ga, line);
+ }
+ char *code = (char *)ga_concat_strings_sep(&ga, "\n");
+ size_t len = strlen(code);
+ nlua_typval_exec(code, len, name, NULL, 0, false, NULL);
+ ga_clear_strings(&ga);
+ xfree(code);
+ return OK;
+}
+
/// Call a LuaCallable given some typvals
///
/// Used to call any lua callable passed from Lua into VimL