From be89d520d7e9ad6c574c259a10f282177fb5dd4a Mon Sep 17 00:00:00 2001 From: bfredl Date: Wed, 13 Nov 2024 13:25:10 +0100 Subject: refactor(windows)!: only support UCRT, even for mingw The newer UCRT runtime has native support for UTF-8, including forcing it as the active codepage even before `main()` is called. This means the c runtime will properly convert windows WCHAR:s into UTF-8 bytes, as early as the argv/argc params to `main()` . Whereas MSVCRT does not support this reliably and required us to use `wmain()`. Only MSVC supports using manifest files directly as source files. The solution for other Windows toolchains is to use a .rc file. --- src/nvim/main.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'src/nvim/main.c') diff --git a/src/nvim/main.c b/src/nvim/main.c index 695bd4c95a..dc4969759d 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -111,6 +111,9 @@ #ifdef MSWIN # include "nvim/os/os_win_console.h" +# ifndef _UCRT +# error UCRT is the only supported C runtime on windows +# endif #endif #if defined(MSWIN) && !defined(MAKE_LIB) @@ -241,22 +244,10 @@ void early_init(mparm_T *paramp) #ifdef MAKE_LIB int nvim_main(int argc, char **argv); // silence -Wmissing-prototypes int nvim_main(int argc, char **argv) -#elif defined(MSWIN) -int wmain(int argc, wchar_t **argv_w) // multibyte args on Windows. #7060 #else int main(int argc, char **argv) #endif { -#if defined(MSWIN) && !defined(MAKE_LIB) - char **argv = xmalloc((size_t)argc * sizeof(char *)); - for (int i = 0; i < argc; i++) { - char *buf = NULL; - utf16_to_utf8(argv_w[i], -1, &buf); - assert(buf); - argv[i] = buf; - } -#endif - argv0 = argv[0]; if (!appname_is_valid()) { -- cgit From 8516c2dc1f301c439695629fff771227dbe00d30 Mon Sep 17 00:00:00 2001 From: Famiu Haque Date: Sat, 23 Nov 2024 14:22:06 +0600 Subject: refactor(options): autogenerate valid values and flag enums for options (#31089) Problem: Option metadata like list of valid values for an option and option flags are not listed in the `options.lua` file and are instead manually defined in C, which means option metadata is split between several places. Solution: Put metadata such as list of valid values for an option and option flags in `options.lua`, and autogenerate the corresponding C variables and enums. Supersedes #28659 Co-authored-by: glepnir --- src/nvim/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/main.c') diff --git a/src/nvim/main.c b/src/nvim/main.c index dc4969759d..17990a6735 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -628,7 +628,7 @@ int main(int argc, char **argv) } // WORKAROUND(mhi): #3023 - if (cb_flags & CB_UNNAMEDMASK) { + if (cb_flags & (kOptCbFlagUnnamed | kOptCbFlagUnnamedplus)) { eval_has_provider("clipboard", false); } -- cgit From 2a7d0ed6145bf3f8b139c2694563f460f829813a Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 23 Dec 2024 05:43:52 -0800 Subject: refactor: iwyu #31637 Result of `make iwyu` (after some "fixups"). --- src/nvim/main.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/nvim/main.c') diff --git a/src/nvim/main.c b/src/nvim/main.c index 17990a6735..348f246d27 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -19,6 +20,7 @@ #endif #include "auto/config.h" // IWYU pragma: keep +#include "klib/kvec.h" #include "nvim/api/extmark.h" #include "nvim/api/private/defs.h" #include "nvim/api/private/helpers.h" @@ -79,9 +81,6 @@ #include "nvim/option.h" #include "nvim/option_defs.h" #include "nvim/option_vars.h" -#include "nvim/optionstr.h" -#include "nvim/os/fileio.h" -#include "nvim/os/fileio_defs.h" #include "nvim/os/fs.h" #include "nvim/os/input.h" #include "nvim/os/lang.h" -- cgit From a1ba655dee0f89230ea09712e4df981cc3b15bea Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Thu, 12 Sep 2024 03:04:33 +0200 Subject: test: spawn_wait() starts a non-RPC Nvim process Problem: Can't use `n.clear()` to test non-RPC `nvim` invocations. So tests end up creating ad-hoc wrappers around `system()` or `jobstart()`. Solution: - Introduce `n.spawn_wait()` - TODO (followup PR): Rename `n.spawn()` and `n.spawn_wait()`. It's misleading that `n.spawn()` returns a RPC session... --- src/nvim/main.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/main.c') diff --git a/src/nvim/main.c b/src/nvim/main.c index 348f246d27..2b55a48c12 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -634,6 +634,7 @@ int main(int argc, char **argv) if (params.luaf != NULL) { // Like "--cmd", "+", "-c" and "-S", don't truncate messages. msg_scroll = true; + DLOG("executing Lua -l script"); bool lua_ok = nlua_exec_file(params.luaf); TIME_MSG("executing Lua -l script"); if (msg_didout) { -- cgit From 5e02a2c47072ec08279b830daa6f82e39ba86c6e Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 5 Jan 2025 17:10:16 -0800 Subject: "nvim -es": disable shada #21723 Problem: `nvim -es` (and `nvim -Es`) is the recommended way to non-interactively run commands/vimscript. But it enables shada by default, which is usually not wanted. Solution: - Disable shada by default for `nvim -es/-Es`. This can be overridden by `-i foo` if needed. - Do NOT change the 'loadplugins' default. - User config + packages _should_ be enabled by default, for both `nvim -es` and `nvim -l`. Else any Lua packages you have can't be accessed without `-u path/to/config`, which is clumsy. - Use-cases: ``` nvim --headless "+Lazy! sync" +qa would become: nvim -es "+Lazy! sync" nvim --headless +PlugInstall +qall would become: nvim -es +PlugInstall ``` - Opt-out (`--clean` or `-u NONE`) is much easier than opt-in (`-u path/to/config`). - User config/packages are analogous to pip packages, which are expected when doing `python -c ...`. related: 7c94bcd2d77e2e54b8836ab8325460a367b79eae related: ddd0eb6f5120a09b97867d2561ea61309038ccd2 --- src/nvim/main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/nvim/main.c') diff --git a/src/nvim/main.c b/src/nvim/main.c index 2b55a48c12..58d110e8b2 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -1228,6 +1228,9 @@ static void command_line_scan(mparm_T *parmp) if (exmode_active) { // "-es" silent (batch) Ex-mode silent_mode = true; parmp->no_swap_file = true; + if (p_shadafile == NULL || *p_shadafile == NUL) { + set_option_value_give_err(kOptShadafile, STATIC_CSTR_AS_OPTVAL("NONE"), 0); + } } else { // "-s {scriptin}" read from script file want_argument = true; } @@ -2085,8 +2088,7 @@ static void source_startup_scripts(const mparm_T *const parmp) { // If -u given, use only the initializations from that file and nothing else. if (parmp->use_vimrc != NULL) { - if (strequal(parmp->use_vimrc, "NONE") - || strequal(parmp->use_vimrc, "NORC")) { + if (strequal(parmp->use_vimrc, "NONE") || strequal(parmp->use_vimrc, "NORC")) { // Do nothing. } else { if (do_source(parmp->use_vimrc, false, DOSO_NONE, NULL) != OK) { -- cgit From d46ebd2a74036a349606213fcd2a8b3530adebcf Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 22 Jan 2025 17:10:29 +0800 Subject: fix(startup): avoid crash with completion from -l script (#32160) Related #27764 --- src/nvim/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/main.c') diff --git a/src/nvim/main.c b/src/nvim/main.c index 58d110e8b2..0bd4277d19 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -360,7 +360,7 @@ int main(int argc, char **argv) setbuf(stdout, NULL); // NOLINT(bugprone-unsafe-functions) - full_screen = !silent_mode || exmode_active; + full_screen = !silent_mode; // Set the default values for the options that use Rows and Columns. win_init_size(); -- cgit