diff options
Diffstat (limited to 'src/nvim/ex_cmds2.c')
-rw-r--r-- | src/nvim/ex_cmds2.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index 56a14887df..4798e93b91 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -27,6 +27,7 @@ #include "nvim/ex_getln.h" #include "nvim/fileio.h" #include "nvim/getchar.h" +#include "nvim/globals.h" #include "nvim/mark.h" #include "nvim/mbyte.h" #include "nvim/memline.h" @@ -53,6 +54,7 @@ #include "nvim/os/fs_defs.h" #include "nvim/api/private/helpers.h" #include "nvim/api/private/defs.h" +#include "nvim/lua/executor.h" /// Growarray to store info about already sourced scripts. @@ -2421,6 +2423,7 @@ void ex_compiler(exarg_T *eap) if (*eap->arg == NUL) { // List all compiler scripts. do_cmdline_cmd("echo globpath(&rtp, 'compiler/*.vim')"); // NOLINT + do_cmdline_cmd("echo globpath(&rtp, 'compiler/*.lua')"); // NOLINT } else { size_t bufsize = STRLEN(eap->arg) + 14; buf = xmalloc(bufsize); @@ -2445,7 +2448,11 @@ void ex_compiler(exarg_T *eap) snprintf((char *)buf, bufsize, "compiler/%s.vim", eap->arg); if (source_in_path(p_rtp, buf, DIP_ALL) == FAIL) { - EMSG2(_("E666: compiler not supported: %s"), eap->arg); + // Try lua compiler + snprintf((char *)buf, bufsize, "compiler/%s.lua", eap->arg); + if (source_in_path(p_rtp, buf, DIP_ALL) == FAIL) { + EMSG2(_("E666: compiler not supported: %s"), eap->arg); + } } xfree(buf); @@ -2656,8 +2663,13 @@ static void cmd_source_buffer(const exarg_T *eap) .curr_lnum = eap->line1, .final_lnum = eap->line2, }; - source_using_linegetter((void *)&cookie, get_buffer_line, - ":source (no file)"); + if (curbuf != NULL && curbuf->b_fname + && path_with_extension((const char *)curbuf->b_fname, "lua")) { + nlua_source_using_linegetter(get_buffer_line, (void *)&cookie, ":source"); + } else { + source_using_linegetter((void *)&cookie, get_buffer_line, + ":source (no file)"); + } } /// ":source" and associated commands. @@ -2769,7 +2781,8 @@ int do_source_str(const char *cmd, const char *traceback_name) return source_using_linegetter((void *)&cookie, get_str_line, traceback_name); } -/// Reads the file `fname` and executes its lines as Ex commands. +/// When fname is a 'lua' file nlua_exec_file() is invoked to source it. +/// Otherwise reads the file `fname` and executes its lines as Ex commands. /// /// This function may be called recursively! /// @@ -2796,6 +2809,10 @@ int do_source(char_u *fname, int check_other, int is_vimrc) proftime_T wait_start; bool trigger_source_post = false; + if (path_with_extension((const char *)fname, "lua")) { + return (int)nlua_exec_file((const char *)fname); + } + p = expand_env_save(fname); if (p == NULL) { return retval; |