From d6d6ab3f8e77d54c8030c0c18f17d3c72ac4445c Mon Sep 17 00:00:00 2001 From: bfredl Date: Sat, 26 Feb 2022 15:19:10 +0100 Subject: feat(lua): low-level interpreter mode (nvim -ll) --- src/nvim/main.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src/nvim/main.c') diff --git a/src/nvim/main.c b/src/nvim/main.c index bbe877356d..8df82c710a 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -239,6 +239,14 @@ int main(int argc, char **argv) argv0 = argv[0]; + if (argc > 1 && STRICMP(argv[1], "-ll") == 0) { + if (argc == 2) { + print_mainerr(err_arg_missing, argv[1]); + exit(1); + } + nlua_run_script(argv, argc, 3); + } + char *fname = NULL; // file name from command line mparm_T params; // various parameters passed between // main() and other functions. @@ -2110,6 +2118,12 @@ static int execute_env(char *env) /// @param str string to append to the primary error message, or NULL static void mainerr(const char *errstr, const char *str) FUNC_ATTR_NORETURN +{ + print_mainerr(errstr, str); + os_exit(1); +} + +static void print_mainerr(const char *errstr, const char *str) { char *prgname = path_tail(argv0); @@ -2126,8 +2140,6 @@ static void mainerr(const char *errstr, const char *str) os_errmsg(_("\nMore info with \"")); os_errmsg(prgname); os_errmsg(" -h\"\n"); - - os_exit(1); } /// Prints version information for "nvim -v" or "nvim --version". -- cgit From 2c5906b55bb6092121f4d3b032d5449da7675c2b Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 2 Feb 2023 10:05:03 +0800 Subject: fix(exit): skip unnecessary steps in TUI preserve_exit() (#21897) This prevents the TUI from doing unexpected things when receiving a deadly signal or running out of memory. --- src/nvim/main.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/nvim/main.c') diff --git a/src/nvim/main.c b/src/nvim/main.c index 8df82c710a..e26922bf8e 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -811,6 +811,11 @@ void preserve_exit(void) really_exiting = true; // Ignore SIGHUP while we are already exiting. #9274 signal_reject_deadly(); + + if (ui_client_channel_id) { + os_exit(1); + } + os_errmsg(IObuff); os_errmsg("\n"); ui_flush(); -- cgit From 69bb145cea56067e6e82ed0a130a51c0d611e540 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 4 Feb 2023 20:14:31 +0800 Subject: refactor(exit): pass error message to preserve_exit() (#22097) Problem: 1. Some calls to preserve_exit() don't put a message in IObuff, so the IObuff printed by preserve_exit() contains unrelated information. 2. If a TUI client runs out of memory or receives a deadly signal, the error message is shown on alternate screen and cannot be easily seen because the TUI exits alternate screen soon afterwards. Solution: Pass error message to preserve_exit() and exit alternate screen before printing it. Note that this doesn't fix the problem that server error messages cannot be easily seen on exit. This is tracked in #21608 and #21843. --- src/nvim/main.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/nvim/main.c') diff --git a/src/nvim/main.c b/src/nvim/main.c index e26922bf8e..2bbe70784d 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -790,10 +790,10 @@ void getout(int exitval) os_exit(exitval); } -/// Preserve files, print contents of `IObuff`, and exit 1. +/// Preserve files, print contents of `errmsg`, and exit 1. /// /// May be called from deadly_signal(). -void preserve_exit(void) +void preserve_exit(const char *errmsg) FUNC_ATTR_NORETURN { // 'true' when we are sure to exit, e.g., after a deadly signal @@ -813,11 +813,14 @@ void preserve_exit(void) signal_reject_deadly(); if (ui_client_channel_id) { - os_exit(1); + // For TUI: exit alternate screen so that the error messages can be seen. + ui_client_stop(); } - - os_errmsg(IObuff); + os_errmsg(errmsg); os_errmsg("\n"); + if (ui_client_channel_id) { + os_exit(1); + } ui_flush(); ml_close_notmod(); // close all not-modified buffers -- cgit From 7224c889e0d5d70b99ae377036baa6377c33a568 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Sat, 11 Feb 2023 10:25:24 +0100 Subject: build: enable MSVC level 3 warnings (#21934) MSVC has 4 different warning levels: 1 (severe), 2 (significant), 3 (production quality) and 4 (informational). Enabling level 3 warnings mostly revealed conversion problems, similar to GCC/clang -Wconversion flag. --- src/nvim/main.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/nvim/main.c') diff --git a/src/nvim/main.c b/src/nvim/main.c index 2bbe70784d..f37c43d8c1 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -182,6 +182,9 @@ void early_init(mparm_T *paramp) #ifdef MSWIN OSVERSIONINFO ovi; ovi.dwOSVersionInfoSize = sizeof(ovi); + // Disable warning about GetVersionExA being deprecated. There doesn't seem to be a conventient + // replacement that doesn't add a ton of extra code as of writing this. +# pragma warning(suppress : 4996) GetVersionEx(&ovi); snprintf(windowsVersion, sizeof(windowsVersion), "%d.%d", (int)ovi.dwMajorVersion, (int)ovi.dwMinorVersion); -- cgit From 4be6c6cf0ddf5e31d4103cb5df06651ba6f4897b Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Sat, 11 Feb 2023 11:05:57 +0100 Subject: refactor: replace char_u with char (#21901) refactor: replace char_u with char Work on https://github.com/neovim/neovim/issues/459 --- 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 f37c43d8c1..4ee02b4e1b 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -1589,7 +1589,7 @@ static void open_script_files(mparm_T *parmp) scriptin[0] = file_open_new(&error, parmp->scriptin, kFileReadOnly|kFileNonBlocking, 0); if (scriptin[0] == NULL) { - vim_snprintf((char *)IObuff, IOSIZE, + vim_snprintf(IObuff, IOSIZE, _("Cannot open for reading: \"%s\": %s\n"), parmp->scriptin, os_strerror(error)); os_errmsg(IObuff); -- cgit From 7d58de11f49c574a8a305e28e96b9ff810493012 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 11 Feb 2023 18:25:01 +0800 Subject: fix(rpc)!: preseve files when stdio channel is closed (#22137) BREAKING CHANGE: Unsaved changes are now preserved rather than discarded when stdio channel is closed. --- src/nvim/main.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src/nvim/main.c') diff --git a/src/nvim/main.c b/src/nvim/main.c index 4ee02b4e1b..f36730a8b3 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -674,6 +674,7 @@ void os_exit(int r) void getout(int exitval) FUNC_ATTR_NORETURN { + assert(!ui_client_channel_id); exiting = true; // On error during Ex mode, exit with a non-zero code. @@ -794,6 +795,7 @@ void getout(int exitval) } /// Preserve files, print contents of `errmsg`, and exit 1. +/// @param errmsg If NULL, this function will not print anything. /// /// May be called from deadly_signal(). void preserve_exit(const char *errmsg) @@ -819,19 +821,21 @@ void preserve_exit(const char *errmsg) // For TUI: exit alternate screen so that the error messages can be seen. ui_client_stop(); } - os_errmsg(errmsg); - os_errmsg("\n"); + if (errmsg != NULL) { + os_errmsg(errmsg); + os_errmsg("\n"); + } if (ui_client_channel_id) { os_exit(1); } - ui_flush(); ml_close_notmod(); // close all not-modified buffers FOR_ALL_BUFFERS(buf) { if (buf->b_ml.ml_mfp != NULL && buf->b_ml.ml_mfp->mf_fname != NULL) { - os_errmsg("Vim: preserving files...\r\n"); - ui_flush(); + if (errmsg != NULL) { + os_errmsg("Vim: preserving files...\r\n"); + } ml_sync_all(false, false, true); // preserve all swap files break; } @@ -839,7 +843,9 @@ void preserve_exit(const char *errmsg) ml_close_all(false); // close all memfiles, without deleting - os_errmsg("Vim: Finished.\r\n"); + if (errmsg != NULL) { + os_errmsg("Vim: Finished.\r\n"); + } getout(1); } -- cgit From c5b34fa55483d84d1de32937ffff0b7cf1aeba78 Mon Sep 17 00:00:00 2001 From: glacambre Date: Sat, 11 Feb 2023 09:45:11 +0100 Subject: refactor: move init_default_autocmds to lua The original motivation for this change came from developping https://github.com/neovim/neovim/pull/22159, which will require adding more autocommand creation to Neovim's startup sequence. This change requires lightly editing a test that expected no autocommand to have been created from lua. --- src/nvim/main.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src/nvim/main.c') diff --git a/src/nvim/main.c b/src/nvim/main.c index 2bbe70784d..1f155aa343 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -404,19 +404,16 @@ int main(int argc, char **argv) open_script_files(¶ms); - // Default mappings (incl. menus) + // Default mappings (incl. menus) & autocommands Error err = ERROR_INIT; - Object o = NLUA_EXEC_STATIC("return vim._init_default_mappings()", + Object o = NLUA_EXEC_STATIC("return vim._init_defaults()", (Array)ARRAY_DICT_INIT, &err); assert(!ERROR_SET(&err)); api_clear_error(&err); assert(o.type == kObjectTypeNil); api_free_object(o); - TIME_MSG("init default mappings"); - - init_default_autocmds(); - TIME_MSG("init default autocommands"); + TIME_MSG("init default mappings & autocommands"); bool vimrc_none = strequal(params.use_vimrc, "NONE"); -- cgit From 27177e581902967dcf4f2f426464da1b636ca420 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Sat, 11 Feb 2023 14:14:24 +0100 Subject: refactor: reduce scope of locals as per the style guide (#22211) --- src/nvim/main.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src/nvim/main.c') diff --git a/src/nvim/main.c b/src/nvim/main.c index f36730a8b3..c12de07077 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -920,9 +920,8 @@ static void remote_request(mparm_T *params, int remote_args, char *server_addr, } Array args = ARRAY_DICT_INIT; - String arg_s; for (int t_argc = remote_args; t_argc < argc; t_argc++) { - arg_s = cstr_to_string(argv[t_argc]); + String arg_s = cstr_to_string(argv[t_argc]); ADD(args, STRING_OBJ(arg_s)); } @@ -1620,9 +1619,6 @@ static void open_script_files(mparm_T *parmp) // Also does recovery if "recoverymode" set. static void create_windows(mparm_T *parmp) { - int dorewind; - int done = 0; - // Create the number of windows that was requested. if (parmp->window_count == -1) { // was not set parmp->window_count = 1; @@ -1658,6 +1654,7 @@ static void create_windows(mparm_T *parmp) } do_modelines(0); // do modelines } else { + int done = 0; // Open a buffer for windows that don't have one yet. // Commands in the vimrc might have loaded a file or split the window. // Watch out for autocommands that delete a window. @@ -1665,7 +1662,7 @@ static void create_windows(mparm_T *parmp) // Don't execute Win/Buf Enter/Leave autocommands here autocmd_no_enter++; autocmd_no_leave++; - dorewind = true; + int dorewind = true; while (done++ < 1000) { if (dorewind) { if (parmp->window_layout == WIN_TABS) { -- cgit From ec782211f2305382b3a6cb72ab0bbfcab0efcdf0 Mon Sep 17 00:00:00 2001 From: Enan Ajmain <3nan.ajmain@gmail.com> Date: Wed, 15 Feb 2023 21:39:23 +0600 Subject: fix(tui): set taskbar, icon in Windows #22270 Problem: After TUI refactor commit, code for setting Windows taskbar icon wasn't being executed because of a backdated conditional. Solution: Update the conditional to take TUI refactor into account. Ref: https://github.com/neovim/neovim/pull/20634#discussion_r1088993820 --- 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 52069a6742..f2aa14e04c 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -589,7 +589,7 @@ int main(int argc, char **argv) } #ifdef MSWIN - if (use_builtin_ui) { + if (use_remote_ui || use_builtin_ui) { os_icon_init(); } os_title_save(); -- cgit From b62c0c8d9c22ae7fc9ee200733f8312efa6dbced Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Mon, 20 Feb 2023 08:12:59 +0100 Subject: docs: fix typos (#21961) Co-authored-by: Ben Morgan --- 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 f2aa14e04c..0ecb5f742d 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -182,7 +182,7 @@ void early_init(mparm_T *paramp) #ifdef MSWIN OSVERSIONINFO ovi; ovi.dwOSVersionInfoSize = sizeof(ovi); - // Disable warning about GetVersionExA being deprecated. There doesn't seem to be a conventient + // Disable warning about GetVersionExA being deprecated. There doesn't seem to be a convenient // replacement that doesn't add a ton of extra code as of writing this. # pragma warning(suppress : 4996) GetVersionEx(&ovi); -- cgit From f1816f9ee2a8b811fd6ce4e60a843087f855f97d Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 20 Feb 2023 15:13:55 +0800 Subject: refactor(main.c): remove unreachable use_builtin_ui conditions (#22338) When use_builtin_ui is true, Nvim will exit before line 385 is reached. --- src/nvim/main.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/nvim/main.c') diff --git a/src/nvim/main.c b/src/nvim/main.c index 0ecb5f742d..5f4e639b06 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -383,6 +383,7 @@ int main(int argc, char **argv) if (ui_client_channel_id) { ui_client_run(remote_ui); // NORETURN } + assert(!ui_client_channel_id && !use_builtin_ui); // Wait for UIs to set up Nvim or show early messages // and prompts (--cmd, swapfile dialog, …). @@ -583,13 +584,13 @@ int main(int argc, char **argv) set_vim_var_nr(VV_VIM_DID_ENTER, 1L); apply_autocmds(EVENT_VIMENTER, NULL, NULL, false, curbuf); TIME_MSG("VimEnter autocommands"); - if (use_remote_ui || use_builtin_ui) { - do_autocmd_uienter(use_remote_ui ? CHAN_STDIO : 0, true); + if (use_remote_ui) { + do_autocmd_uienter(CHAN_STDIO, true); TIME_MSG("UIEnter autocommands"); } #ifdef MSWIN - if (use_remote_ui || use_builtin_ui) { + if (use_remote_ui) { os_icon_init(); } os_title_save(); -- cgit From cf07f2baabd3a1a072102e0cacb6d70509ada044 Mon Sep 17 00:00:00 2001 From: bfredl Date: Mon, 27 Feb 2023 12:29:20 +0100 Subject: feat(edit)!: remove old c implementation of hebrew keymap This feature has long been obsolete. The 'keymap' option can be used to support language keymaps, including hebrew and hebrewp (phonetic mapping). There is no need to keep the old c code with hardcoded keymaps for some languages. --- src/nvim/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/main.c') diff --git a/src/nvim/main.c b/src/nvim/main.c index 5f4e639b06..975772169b 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -1147,8 +1147,8 @@ static void command_line_scan(mparm_T *parmp) case 'h': // "-h" give help message usage(); os_exit(0); - case 'H': // "-H" start in Hebrew mode: rl + hkmap set. - p_hkmap = true; + case 'H': // "-H" start in Hebrew mode: rl + keymap=hebrew set. + set_option_value_give_err("keymap", 0L, "hebrew", 0); set_option_value_give_err("rl", 1L, NULL, 0); break; case 'M': // "-M" no changes or writing of files -- cgit From 1b3c1f6c06d73e881bfc2a46e5ee3e0b24ba96d8 Mon Sep 17 00:00:00 2001 From: bfredl Date: Mon, 27 Feb 2023 19:37:43 +0100 Subject: refactor(build): graduate HAVE_LOCALE_H feature Merge locale.h into os/lang.h Having a source file with the same name as a system header we use is considered an anti-pattern. --- src/nvim/main.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/nvim/main.c') diff --git a/src/nvim/main.c b/src/nvim/main.c index 975772169b..71c5c2af46 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -41,7 +41,6 @@ #include "nvim/highlight.h" #include "nvim/highlight_group.h" #include "nvim/keycodes.h" -#include "nvim/locale.h" #include "nvim/log.h" #include "nvim/lua/executor.h" #include "nvim/macros.h" @@ -60,6 +59,7 @@ #include "nvim/optionstr.h" #include "nvim/os/fileio.h" #include "nvim/os/input.h" +#include "nvim/os/lang.h" #include "nvim/os/os.h" #include "nvim/os/stdpaths_defs.h" #include "nvim/os/time.h" @@ -192,12 +192,10 @@ void early_init(mparm_T *paramp) TIME_MSG("early init"); -#if defined(HAVE_LOCALE_H) // Setup to use the current locale (for ctype() and many other things). // NOTE: Translated messages with encodings other than latin1 will not // work until set_init_1() has been called! init_locale(); -#endif // tabpage local options (p_ch) must be set before allocating first tabpage. set_init_tablocal(); -- cgit From 07758587037de1c8a4c45f1b39722ae73522c6bd Mon Sep 17 00:00:00 2001 From: Biswapriyo Nath Date: Sun, 5 Mar 2023 19:22:32 +0530 Subject: build: fix unknown pragma warning with mingw (#22533) This checks MSVC toolchain with _MSC_VER macro before adding pragma warning directive. It is specific to MSVC and shows compiler warning with mingw gcc as following: main.c:187: warning: ignoring '#pragma warning ' [-Wunknown-pragmas] 187 | # pragma warning(suppress : 4996) --- src/nvim/main.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/nvim/main.c') diff --git a/src/nvim/main.c b/src/nvim/main.c index 71c5c2af46..be1714b207 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -184,8 +184,12 @@ void early_init(mparm_T *paramp) ovi.dwOSVersionInfoSize = sizeof(ovi); // Disable warning about GetVersionExA being deprecated. There doesn't seem to be a convenient // replacement that doesn't add a ton of extra code as of writing this. -# pragma warning(suppress : 4996) +# ifdef _MSC_VER +# pragma warning(suppress : 4996) GetVersionEx(&ovi); +# else + GetVersionEx(&ovi); +# endif snprintf(windowsVersion, sizeof(windowsVersion), "%d.%d", (int)ovi.dwMajorVersion, (int)ovi.dwMinorVersion); #endif -- cgit From 7dc9182cf0b27cbfb4e289db55dd7b02998ef5c8 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 11 Mar 2023 21:29:25 +0800 Subject: vim-patch:8.2.1398: autoload script sourced twice if sourced directly (#22622) Problem: Autoload script sourced twice if sourced directly. Solution: Do not source an autoload script again. (issue vim/vim#6644) https://github.com/vim/vim/commit/daa2f36573db3e1df7eb1fdbc3a09a2815644048 Cherry-pick ret_sid changes from patch 8.2.0149. Use do_in_runtimepath() as that's what source_runtime() calls in Nvim. Co-authored-by: Bram Moolenaar --- src/nvim/main.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/nvim/main.c') diff --git a/src/nvim/main.c b/src/nvim/main.c index be1714b207..ea5f511fc6 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -1937,7 +1937,7 @@ static void do_system_initialization(void) dir_len += 1; } memcpy(vimrc + dir_len, path_tail, sizeof(path_tail)); - if (do_source(vimrc, false, DOSO_NONE) != FAIL) { + if (do_source(vimrc, false, DOSO_NONE, NULL) != FAIL) { xfree(vimrc); xfree(config_dirs); return; @@ -1949,7 +1949,7 @@ static void do_system_initialization(void) #ifdef SYS_VIMRC_FILE // Get system wide defaults, if the file name is defined. - (void)do_source(SYS_VIMRC_FILE, false, DOSO_NONE); + (void)do_source(SYS_VIMRC_FILE, false, DOSO_NONE, NULL); #endif } @@ -1978,7 +1978,7 @@ static bool do_user_initialization(void) // init.lua if (os_path_exists(init_lua_path) - && do_source(init_lua_path, true, DOSO_VIMRC)) { + && do_source(init_lua_path, true, DOSO_VIMRC, NULL)) { if (os_path_exists(user_vimrc)) { semsg(_("E5422: Conflicting configs: \"%s\" \"%s\""), init_lua_path, user_vimrc); @@ -1992,7 +1992,7 @@ static bool do_user_initialization(void) xfree(init_lua_path); // init.vim - if (do_source(user_vimrc, true, DOSO_VIMRC) != FAIL) { + if (do_source(user_vimrc, true, DOSO_VIMRC, NULL) != FAIL) { do_exrc = p_exrc; if (do_exrc) { do_exrc = (path_full_compare(VIMRC_FILE, user_vimrc, false, true) != kEqualFiles); @@ -2018,7 +2018,7 @@ static bool do_user_initialization(void) memmove(vimrc, dir, dir_len); vimrc[dir_len] = PATHSEP; memmove(vimrc + dir_len + 1, path_tail, sizeof(path_tail)); - if (do_source(vimrc, true, DOSO_VIMRC) != FAIL) { + if (do_source(vimrc, true, DOSO_VIMRC, NULL) != FAIL) { do_exrc = p_exrc; if (do_exrc) { do_exrc = (path_full_compare(VIMRC_FILE, vimrc, false, true) != kEqualFiles); @@ -2084,7 +2084,7 @@ static void source_startup_scripts(const mparm_T *const parmp) || strequal(parmp->use_vimrc, "NORC")) { // Do nothing. } else { - if (do_source(parmp->use_vimrc, false, DOSO_NONE) != OK) { + if (do_source(parmp->use_vimrc, false, DOSO_NONE, NULL) != OK) { semsg(_("E282: Cannot read from \"%s\""), parmp->use_vimrc); } } -- cgit From b02880593e281ce44661ce22e9391edfe921e47e Mon Sep 17 00:00:00 2001 From: luukvbaal <31730729+luukvbaal@users.noreply.github.com> Date: Thu, 23 Mar 2023 12:58:50 +0100 Subject: build(win): export extern symbols for use in FFI #22756 Makes `extern` variables accessible through ffi on Windows. Follow-up to https://github.com/neovim/neovim/pull/15999 --- src/nvim/main.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/nvim/main.c') diff --git a/src/nvim/main.c b/src/nvim/main.c index ea5f511fc6..a16badc1a0 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -1,7 +1,12 @@ // This is an open source non-commercial project. Dear PVS-Studio, please check // it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com -#define EXTERN +// Make sure extern symbols are exported on Windows +#ifdef WIN32 +# define EXTERN __declspec(dllexport) +#else +# define EXTERN +#endif #include #include #include -- cgit From d5f6176e6dc4b4e12fc5061ca6e87f4af533e46a Mon Sep 17 00:00:00 2001 From: ii14 <59243201+ii14@users.noreply.github.com> Date: Sat, 1 Apr 2023 02:49:51 +0200 Subject: refactor: add const and remove unnecessary casts (#22841) --- 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 a16badc1a0..1f16ecff76 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -2153,7 +2153,7 @@ static void print_mainerr(const char *errstr, const char *str) os_errmsg(_(errstr)); if (str != NULL) { os_errmsg(": \""); - os_errmsg((char *)str); + os_errmsg(str); os_errmsg("\""); } os_errmsg(_("\nMore info with \"")); -- cgit From 04933b1ea968f958d2541dd65fd33ebb503caac3 Mon Sep 17 00:00:00 2001 From: ii14 <59243201+ii14@users.noreply.github.com> Date: Fri, 7 Apr 2023 21:08:16 +0200 Subject: refactor: remove redundant casts --- 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 1f16ecff76..0ef1fc9391 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -2122,7 +2122,7 @@ static int execute_env(char *env) current_sctx.sc_sid = SID_ENV; current_sctx.sc_seq = 0; current_sctx.sc_lnum = 0; - do_cmdline_cmd((char *)initstr); + do_cmdline_cmd(initstr); estack_pop(); current_sctx = save_current_sctx; -- cgit From 7b05ddbb72717f995fedc81583d73f82c78c881d Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 16 Apr 2023 11:37:41 +0800 Subject: vim-patch:9.0.0397: :defer not tested with exceptions and ":qa!" Problem: :defer not tested with exceptions and ":qa!". Solution: Test :defer works when exceptions are thrown and when ":qa!" is used. Invoke the deferred calls on exit. https://github.com/vim/vim/commit/58779858fb5a82a3233af5d4237a3cece88c10d4 Co-authored-by: Bram Moolenaar --- src/nvim/main.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/nvim/main.c') diff --git a/src/nvim/main.c b/src/nvim/main.c index 0ef1fc9391..698c2dcc4f 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -30,6 +30,7 @@ #include "nvim/eval.h" #include "nvim/eval/typval.h" #include "nvim/eval/typval_defs.h" +#include "nvim/eval/userfunc.h" #include "nvim/event/multiqueue.h" #include "nvim/event/stream.h" #include "nvim/ex_cmds.h" @@ -693,6 +694,9 @@ void getout(int exitval) // Position the cursor on the last screen line, below all the text ui_cursor_goto(Rows - 1, 0); + // Invoked all deferred functions in the function stack. + invoke_all_defer(); + // Optionally print hashtable efficiency. hash_debug_results(); -- cgit From 85c61d67160133ba53762bc1e5e7bbd7a0c582c0 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 19 Apr 2023 10:06:34 +0800 Subject: vim-patch:9.0.1007: there is no way to get a list of swap file names Problem: There is no way to get a list of swap file names. Solution: Add the swapfilelist() function. Use it in the test script to clean up. Remove deleting individual swap files. https://github.com/vim/vim/commit/c216a7a21a25a701b84b79abc1ba6ab0baa3a311 vim-patch:9.0.1005: a failed test may leave a swap file behind Problem: A failed test may leave a swap file behind. Solution: Delete the swap file to avoid another test to fail. Use another file name. https://github.com/vim/vim/commit/d0f8d39d20f8d42f7451f781f7be0bcd20e06741 Cherry-pick test_window_cmd.vim changes from patch 8.2.1593. Remove FUNC_ATTR_UNUSED from eval functions as fptr is always unused. Co-authored-by: Bram Moolenaar --- 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 698c2dcc4f..6ff26b6e96 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -466,7 +466,7 @@ int main(int argc, char **argv) // Recovery mode without a file name: List swap files. // Uses the 'dir' option, therefore it must be after the initializations. if (recoverymode && fname == NULL) { - recover_names(NULL, true, 0, NULL); + recover_names(NULL, true, NULL, 0, NULL); os_exit(0); } -- cgit From b773a525157393fca26967bd400edf137839e545 Mon Sep 17 00:00:00 2001 From: bfredl Date: Thu, 20 Apr 2023 18:54:00 +0200 Subject: refactor(env): remove unused mutex This was needed when TUI was a thread. lua code uses os_getenv only on the main thread. --- src/nvim/main.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src/nvim/main.c') diff --git a/src/nvim/main.c b/src/nvim/main.c index 6ff26b6e96..db366160f6 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -176,7 +176,6 @@ bool event_teardown(void) /// Needed for unit tests. Must be called after `time_init()`. void early_init(mparm_T *paramp) { - env_init(); estack_init(); cmdline_init(); eval_init(); // init global variables -- cgit From 0d2fe7786537ef63d0d3ed1e94546eb3ee35a368 Mon Sep 17 00:00:00 2001 From: bfredl Date: Sun, 23 Apr 2023 19:02:23 +0200 Subject: refactor(time): refactor delay with input checking MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, there were three low-level delay entry points - os_delay(ms, ignoreinput=true): sleep for ms, only break on got_int - os_delay(ms, ignoreinput=false): sleep for ms, break on any key input os_microdelay(us, false): equivalent, but in μs (not directly called) - os_microdelay(us, true): sleep for μs, never break. The implementation of the latter two both used uv_cond_timedwait() This could have been for two reasons: 1. allow another thread to "interrupt" the wait 2. uv_cond_timedwait() has higher resolution than uv_sleep() However we (1) never used the first, even when TUI was a thread, and (2) nowhere in the codebase are we using μs resolution, it is always a ms multiplied with 1000. In addition, os_delay(ms, false) would completely block the thread for 100ms intervals and in between check for input. This is not how event handling is done alound here. Therefore: Replace the implementation of os_delay(ms, false) to use LOOP_PROCESS_EVENTS_UNTIL which does a proper epoll wait with a timeout, instead of the 100ms timer panic. Replace os_microdelay(us, false) with a direct wrapper of uv_sleep. --- src/nvim/main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/nvim/main.c') diff --git a/src/nvim/main.c b/src/nvim/main.c index db366160f6..657f9c67f2 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -173,7 +173,7 @@ bool event_teardown(void) /// Performs early initialization. /// -/// Needed for unit tests. Must be called after `time_init()`. +/// Needed for unit tests. void early_init(mparm_T *paramp) { estack_init(); @@ -261,7 +261,6 @@ int main(int argc, char **argv) mparm_T params; // various parameters passed between // main() and other functions. char *cwd = NULL; // current working dir on startup - time_init(); // Many variables are in `params` so that we can pass them around easily. // `argc` and `argv` are also copied, so that they can be changed. -- cgit From 5e569a47031d2a5b94cfadd67d5e76ba4651ac4d Mon Sep 17 00:00:00 2001 From: bfredl Date: Tue, 25 Apr 2023 13:39:28 +0200 Subject: refactor(fs): now it is time to get rid of fs_loop and fs_loop_mutex Here's the headline: when run in sync mode (last argument cb=NULL), these functions don't actually use the uv_loop_t. An earlier version of this patch instead replaced fs_loop with using main_loop.uv on the main thread and luv_loop() on luv worker threads. However this made the code more complicated for no reason. Also arbitrarily, half of these functions would attempt to handle UV_ENOMEM by try_to_free_memory(). This would mostly happen on windows because it needs to allocate a converted WCHAR buffer. This should be a quite rare situation. Your system is pretty much hosed already if you cannot allocate like 50 WCHAR:s. Therefore, take the liberty of simply removing this fallback. In addition, we tried to "recover" from ENOMEM in read()/readv() this way which doesn't make any sense. The read buffer(s) are already allocated at this point. This would also be an issue when using these functions on a worker thread, as try_to_free_memory() is not thread-safe. Currently os_file_is_readable() and os_is_dir() is used by worker threads (as part of nvim__get_runtime(), to implement require from 'rtp' in threads). In the end, these changes makes _all_ os/fs.c functions thread-safe, and we thus don't need to document and maintain a thread-safe subset. --- src/nvim/main.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'src/nvim/main.c') diff --git a/src/nvim/main.c b/src/nvim/main.c index 657f9c67f2..60390c3c60 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -266,10 +266,6 @@ int main(int argc, char **argv) // `argc` and `argv` are also copied, so that they can be changed. init_params(¶ms, argc, argv); - // Since os_open is called during the init_startuptime, we need to call - // fs_init before it. - fs_init(); - init_startuptime(¶ms); // Need to find "--clean" before actually parsing arguments. @@ -1479,7 +1475,7 @@ static void init_startuptime(mparm_T *paramp) { for (int i = 1; i < paramp->argc - 1; i++) { if (STRICMP(paramp->argv[i], "--startuptime") == 0) { - time_fd = os_fopen(paramp->argv[i + 1], "a"); + time_fd = fopen(paramp->argv[i + 1], "a"); time_start("--- NVIM STARTING ---"); break; } -- cgit From 4f235e3cafba5dc305aa0be33cdec093e9c5a92d Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 28 Apr 2023 20:26:02 +0800 Subject: fix(tui): position cursor at bottom-left before stopping (#23369) Fix #23361 --- src/nvim/main.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'src/nvim/main.c') diff --git a/src/nvim/main.c b/src/nvim/main.c index 60390c3c60..4b96f5839d 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -685,9 +685,6 @@ void getout(int exitval) set_vim_var_nr(VV_EXITING, exitval); - // Position the cursor on the last screen line, below all the text - ui_cursor_goto(Rows - 1, 0); - // Invoked all deferred functions in the function stack. invoke_all_defer(); @@ -776,9 +773,6 @@ void getout(int exitval) wait_return(false); } - // Position the cursor again, the autocommands may have moved it - ui_cursor_goto(Rows - 1, 0); - // Apply 'titleold'. if (p_title && *p_titleold != NUL) { ui_call_set_title(cstr_as_string(p_titleold)); -- cgit From 4bfc7802f056c2e1284edad3f8b7943f7f25d493 Mon Sep 17 00:00:00 2001 From: Enan Ajmain <3nan.ajmain@gmail.com> Date: Sun, 7 May 2023 20:44:03 +0600 Subject: fix(windows): set stdout to binary mode for --api-info Problem: --api-info output is binary. Not setting the mode may cause the OS to impose unexpected eof. For Windows, it scatters extra '0d0a' words in the output. Solution: On Windows, set stdout to binary mode for --api-info. Fixes #20977 --- src/nvim/main.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/nvim/main.c') diff --git a/src/nvim/main.c b/src/nvim/main.c index 4b96f5839d..ee643adab5 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -1056,6 +1056,10 @@ static void command_line_scan(mparm_T *parmp) version(); os_exit(0); } else if (STRICMP(argv[0] + argv_idx, "api-info") == 0) { +#ifdef MSWIN + // set stdout to binary to avoid crlf in --api-info output + _setmode(STDOUT_FILENO, _O_BINARY); +#endif FileDescriptor fp; const int fof_ret = file_open_fd(&fp, STDOUT_FILENO, kFileWriteOnly); -- cgit From 08991b078267e5de0a19a136d00d4f71ad651a32 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Sat, 13 May 2023 21:33:22 +0200 Subject: docs: small fixes Co-authored-by: Christian Clason Co-authored-by: Gregory Anders Co-authored-by: HiPhish Co-authored-by: Julio B Co-authored-by: T727 <74924917+T-727@users.noreply.github.com> Co-authored-by: camoz Co-authored-by: champignoom <66909116+champignoom@users.noreply.github.com> --- src/nvim/main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/nvim/main.c') diff --git a/src/nvim/main.c b/src/nvim/main.c index 4b96f5839d..659eccc6f0 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -443,8 +443,7 @@ int main(int argc, char **argv) // If using the runtime (-u is not NONE), enable syntax & filetype plugins. if (!vimrc_none || params.clean) { - // Sources filetype.lua and filetype.vim unless the user explicitly disabled it with :filetype - // off. + // Sources filetype.lua unless the user explicitly disabled it with :filetype off. filetype_maybe_enable(); // Sources syntax/syntax.vim. We do this *after* the user startup scripts so that users can // disable syntax highlighting with `:syntax off` if they wish. -- cgit From 4cc69f45b4a56c1c0f0ac8ac15b66dffe00d4615 Mon Sep 17 00:00:00 2001 From: ii14 Date: Sat, 22 Apr 2023 03:27:32 +0200 Subject: build: add ubsan default options Use print_stacktrace=1 for UBSAN by default. --- src/nvim/main.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/nvim/main.c') diff --git a/src/nvim/main.c b/src/nvim/main.c index 659eccc6f0..4999d9dd2a 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -2222,3 +2222,17 @@ static void check_swap_exists_action(void) } handle_swap_exists(NULL); } + +#ifdef ENABLE_ASAN_UBSAN +const char *__ubsan_default_options(void); +const char *__ubsan_default_options(void) +{ + return "print_stacktrace=1"; +} + +const char *__asan_default_options(void); +const char *__asan_default_options(void) +{ + return "handle_abort=1,handle_sigill=1"; +} +#endif -- cgit From 01ea42c32afe8d235d2110a5fcf12a353a7d2a71 Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Mon, 22 May 2023 09:24:36 +0100 Subject: refactor(vim.secure): move to lua/secure.c --- 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 4999d9dd2a..6015bbd06e 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -49,6 +49,7 @@ #include "nvim/keycodes.h" #include "nvim/log.h" #include "nvim/lua/executor.h" +#include "nvim/lua/secure.h" #include "nvim/macros.h" #include "nvim/main.h" #include "nvim/mark.h" -- cgit From 5a3752889c5b7e18d1041eb873ca2fa9ceb814bd Mon Sep 17 00:00:00 2001 From: Ghjuvan Lacambre Date: Sun, 28 May 2023 16:04:54 +0200 Subject: fix(NVIM_APPNAME): show error message if $NVIM_APPNAME is invalid Closes https://github.com/neovim/neovim/issues/23056. --- src/nvim/main.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/nvim/main.c') diff --git a/src/nvim/main.c b/src/nvim/main.c index d4fbf8ce93..f27ebb2f67 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -250,6 +250,11 @@ int main(int argc, char **argv) argv0 = argv[0]; + if (!appname_is_valid()) { + os_errmsg("$NVIM_APPNAME is not a valid file name.\n"); + exit(1); + } + if (argc > 1 && STRICMP(argv[1], "-ll") == 0) { if (argc == 2) { print_mainerr(err_arg_missing, argv[1]); -- cgit From b3d5138fd0066fda26ef7724a542ae45eb42fc84 Mon Sep 17 00:00:00 2001 From: Famiu Haque Date: Wed, 7 Jun 2023 06:05:16 +0600 Subject: refactor(options): remove `getoption_T` and introduce `OptVal` (#23850) Removes the `getoption_T` struct and also introduces the `OptVal` struct to unify the methods of getting/setting different option value types. This is the first of many PRs to reduce code duplication in the Vim option code as well as to make options easier to maintain. It also increases the flexibility and extensibility of options. Which opens the door for things like Array and Dictionary options. --- src/nvim/main.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/nvim/main.c') diff --git a/src/nvim/main.c b/src/nvim/main.c index f27ebb2f67..88eedf80d3 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -1112,7 +1112,7 @@ static void command_line_scan(mparm_T *parmp) } else if (STRNICMP(argv[0] + argv_idx, "clean", 5) == 0) { parmp->use_vimrc = "NONE"; parmp->clean = true; - set_option_value_give_err("shadafile", 0L, "NONE", 0); + set_option_value_give_err("shadafile", STATIC_CSTR_AS_OPTVAL("NONE"), 0); } else if (STRNICMP(argv[0] + argv_idx, "luamod-dev", 9) == 0) { nlua_disable_preload = true; } else { @@ -1126,7 +1126,7 @@ static void command_line_scan(mparm_T *parmp) } break; case 'A': // "-A" start in Arabic mode. - set_option_value_give_err("arabic", 1L, NULL, 0); + set_option_value_give_err("arabic", BOOLEAN_OPTVAL(true), 0); break; case 'b': // "-b" binary mode. // Needs to be effective before expanding file names, because @@ -1156,8 +1156,8 @@ static void command_line_scan(mparm_T *parmp) usage(); os_exit(0); case 'H': // "-H" start in Hebrew mode: rl + keymap=hebrew set. - set_option_value_give_err("keymap", 0L, "hebrew", 0); - set_option_value_give_err("rl", 1L, NULL, 0); + set_option_value_give_err("keymap", STATIC_CSTR_AS_OPTVAL("hebrew"), 0); + set_option_value_give_err("rl", BOOLEAN_OPTVAL(true), 0); break; case 'M': // "-M" no changes or writing of files reset_modifiable(); @@ -1237,7 +1237,7 @@ static void command_line_scan(mparm_T *parmp) // default is 10: a little bit verbose p_verbose = get_number_arg(argv[0], &argv_idx, 10); if (argv[0][argv_idx] != NUL) { - set_option_value_give_err("verbosefile", 0L, argv[0] + argv_idx, 0); + set_option_value_give_err("verbosefile", CSTR_AS_OPTVAL(argv[0] + argv_idx), 0); argv_idx = (int)strlen(argv[0]); } break; @@ -1245,7 +1245,7 @@ static void command_line_scan(mparm_T *parmp) // "-w {scriptout}" write to script if (ascii_isdigit((argv[0])[argv_idx])) { n = get_number_arg(argv[0], &argv_idx, 10); - set_option_value_give_err("window", n, NULL, 0); + set_option_value_give_err("window", NUMBER_OPTVAL(n), 0); break; } want_argument = true; @@ -1341,7 +1341,7 @@ static void command_line_scan(mparm_T *parmp) break; case 'i': // "-i {shada}" use for shada - set_option_value_give_err("shadafile", 0L, argv[0], 0); + set_option_value_give_err("shadafile", CSTR_AS_OPTVAL(argv[0]), 0); break; case 'l': // "-l" Lua script: args after "-l". @@ -1351,7 +1351,7 @@ static void command_line_scan(mparm_T *parmp) parmp->no_swap_file = true; parmp->use_vimrc = parmp->use_vimrc ? parmp->use_vimrc : "NONE"; if (p_shadafile == NULL || *p_shadafile == NUL) { - set_option_value_give_err("shadafile", 0L, "NONE", 0); + set_option_value_give_err("shadafile", STATIC_CSTR_AS_OPTVAL("NONE"), 0); } parmp->luaf = argv[0]; argc--; @@ -1387,7 +1387,7 @@ scripterror: if (ascii_isdigit(*(argv[0]))) { argv_idx = 0; n = get_number_arg(argv[0], &argv_idx, 10); - set_option_value_give_err("window", n, NULL, 0); + set_option_value_give_err("window", NUMBER_OPTVAL(n), 0); argv_idx = -1; break; } @@ -1782,7 +1782,7 @@ static void edit_buffers(mparm_T *parmp, char *cwd) p_shm_save = xstrdup(p_shm); snprintf(buf, sizeof(buf), "F%s", p_shm); - set_option_value_give_err("shm", 0L, buf, 0); + set_option_value_give_err("shm", CSTR_AS_OPTVAL(buf), 0); } } else { if (curwin->w_next == NULL) { // just checking @@ -1826,7 +1826,7 @@ static void edit_buffers(mparm_T *parmp, char *cwd) } if (p_shm_save != NULL) { - set_option_value_give_err("shm", 0L, p_shm_save, 0); + set_option_value_give_err("shm", CSTR_AS_OPTVAL(p_shm_save), 0); xfree(p_shm_save); } -- cgit From cce9460524aa17bcd4daa095f4706220b81f8845 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 11 Jun 2023 15:29:51 +0800 Subject: fix(remote): make --remote-expr print to stdout (#23980) --- src/nvim/main.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/nvim/main.c') diff --git a/src/nvim/main.c b/src/nvim/main.c index 88eedf80d3..6a02aa3dae 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -953,7 +953,7 @@ static void remote_request(mparm_T *params, int remote_args, char *server_addr, TriState tabbed = kNone; for (size_t i = 0; i < rvobj.data.dictionary.size; i++) { - if (strcmp(rvobj.data.dictionary.items[i].key.data, "errmsg") == 0) { + if (strequal(rvobj.data.dictionary.items[i].key.data, "errmsg")) { if (rvobj.data.dictionary.items[i].value.type != kObjectTypeString) { os_errmsg("vim._cs_remote returned an unexpected type for 'errmsg'\n"); os_exit(2); @@ -961,13 +961,20 @@ static void remote_request(mparm_T *params, int remote_args, char *server_addr, os_errmsg(rvobj.data.dictionary.items[i].value.data.string.data); os_errmsg("\n"); os_exit(2); - } else if (strcmp(rvobj.data.dictionary.items[i].key.data, "tabbed") == 0) { + } else if (strequal(rvobj.data.dictionary.items[i].key.data, "result")) { + if (rvobj.data.dictionary.items[i].value.type != kObjectTypeString) { + os_errmsg("vim._cs_remote returned an unexpected type for 'result'\n"); + os_exit(2); + } + os_msg(rvobj.data.dictionary.items[i].value.data.string.data); + os_msg("\n"); + } else if (strequal(rvobj.data.dictionary.items[i].key.data, "tabbed")) { if (rvobj.data.dictionary.items[i].value.type != kObjectTypeBoolean) { os_errmsg("vim._cs_remote returned an unexpected type for 'tabbed'\n"); os_exit(2); } tabbed = rvobj.data.dictionary.items[i].value.data.boolean ? kTrue : kFalse; - } else if (strcmp(rvobj.data.dictionary.items[i].key.data, "should_exit") == 0) { + } else if (strequal(rvobj.data.dictionary.items[i].key.data, "should_exit")) { if (rvobj.data.dictionary.items[i].value.type != kObjectTypeBoolean) { os_errmsg("vim._cs_remote returned an unexpected type for 'should_exit'\n"); os_exit(2); -- cgit From bde59e81473f29944ef80ff98f6b2c88010b2df6 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 11 Jun 2023 22:12:32 +0800 Subject: fix(remote): restore previous --remote-expr output formatting (#23988) - Use tostring() as that's what print() uses internally. - Do not append trailing new line. --- src/nvim/main.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src/nvim/main.c') diff --git a/src/nvim/main.c b/src/nvim/main.c index 6a02aa3dae..6ab7391b05 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -967,7 +967,6 @@ static void remote_request(mparm_T *params, int remote_args, char *server_addr, os_exit(2); } os_msg(rvobj.data.dictionary.items[i].value.data.string.data); - os_msg("\n"); } else if (strequal(rvobj.data.dictionary.items[i].key.data, "tabbed")) { if (rvobj.data.dictionary.items[i].value.type != kObjectTypeBoolean) { os_errmsg("vim._cs_remote returned an unexpected type for 'tabbed'\n"); -- cgit From cee981bf09c81ab4b2fe6facf45076ea4bac46a5 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 19 Jun 2023 02:24:44 -0700 Subject: docs #22363 Co-authored by: zeertzjq Co-authored by: Steven Todd McIntyre II <114119064+stmii@users.noreply.github.com> Co-authored by: nobe4 - docs: mention --luadev-mod to run with lua runtime files When changing a lua file in the ./runtime folder, a new contributor might expect changes to be applied to the built Neovim binary. --- src/nvim/main.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) (limited to 'src/nvim/main.c') diff --git a/src/nvim/main.c b/src/nvim/main.c index 6ab7391b05..83e56c3066 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -2185,43 +2185,33 @@ static void usage(void) signal_stop(); // kill us with CTRL-C here, if you like os_msg(_("Usage:\n")); - os_msg(_(" nvim [options] [file ...] Edit file(s)\n")); - os_msg(_(" nvim [options] -t Edit file where tag is defined\n")); - os_msg(_(" nvim [options] -q [errorfile] Edit file with first error\n")); + os_msg(_(" nvim [options] [file ...]\n")); os_msg(_("\nOptions:\n")); - os_msg(_(" -- Only file names after this\n")); - os_msg(_(" + Start at end of file\n")); os_msg(_(" --cmd Execute before any config\n")); os_msg(_(" +, -c Execute after config and first file\n")); os_msg(_(" -l