aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/main.c
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2023-01-01 03:14:13 +0100
committerJustin M. Keyes <justinkz@gmail.com>2023-01-05 17:10:02 +0100
commit45549f031ee52a01601c33acc411f3111cfc4e95 (patch)
treeb9c772a2ba9b0f226f5f6926417d22b0a0f3f207 /src/nvim/main.c
parent599e1d019aa010d4e3c56e6bad3d1c406dda5b0f (diff)
downloadrneovim-45549f031ee52a01601c33acc411f3111cfc4e95.tar.gz
rneovim-45549f031ee52a01601c33acc411f3111cfc4e95.tar.bz2
rneovim-45549f031ee52a01601c33acc411f3111cfc4e95.zip
feat(lua): send "--" literally to Lua "-l" script
Problem: When "-l" is followed by "--", we stop sending args to the Lua script and treat "--" in the usual way. This was for flexibility but didn't have a strong use-case, and has these problems: - prevents Lua "-l" scripts from handling "--" in their own way. - complicates the startup logic (must call nlua_init before command_line_scan) Solution: Don't treat "--" specially if it follows "-l".
Diffstat (limited to 'src/nvim/main.c')
-rw-r--r--src/nvim/main.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/src/nvim/main.c b/src/nvim/main.c
index 77584b049a..908395655f 100644
--- a/src/nvim/main.c
+++ b/src/nvim/main.c
@@ -275,14 +275,14 @@ int main(int argc, char **argv)
// Check if we have an interactive window.
check_and_set_isatty(&params);
- // TODO: should we try to keep param scan before this?
- nlua_init();
- TIME_MSG("init lua interpreter");
-
// Process the command line arguments. File names are put in the global
// argument list "global_alist".
command_line_scan(&params);
+ nlua_init();
+ nlua_set_argv(argv, argc, params.lua_arg0);
+ TIME_MSG("init lua interpreter");
+
if (embedded_mode) {
const char *err;
if (!channel_from_stdio(true, CALLBACK_READER_INIT, &err)) {
@@ -1318,14 +1318,9 @@ static void command_line_scan(mparm_T *parmp)
}
parmp->luaf = argv[0];
argc--;
- argv++;
- // Lua args after "-l <file>" (upto "--").
- int l_argc = nlua_set_argv(argv, argc);
- assert(l_argc >= 0);
- argc = argc - l_argc;
- if (argc > 0) { // Found "--".
- argv = argv + l_argc;
- had_minmin = true;
+ if (argc > 0) { // Lua args after "-l <file>".
+ parmp->lua_arg0 = parmp->argc - argc;
+ argc = 0;
}
break;
@@ -1438,6 +1433,7 @@ static void init_params(mparm_T *paramp, int argc, char **argv)
paramp->server_addr = NULL;
paramp->remote = 0;
paramp->luaf = NULL;
+ paramp->lua_arg0 = -1;
}
/// Initialize global startuptime file if "--startuptime" passed as an argument.