From fb1edb2f5728d74ae811c6ab32395598cea5609b Mon Sep 17 00:00:00 2001 From: Dundar Göc Date: Fri, 26 Aug 2022 23:11:25 +0200 Subject: refactor: replace char_u with char Work on https://github.com/neovim/neovim/issues/459 --- src/nvim/ex_cmds2.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/nvim/ex_cmds2.c') diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index 11280eecbb..e551cbee0b 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -200,9 +200,9 @@ void dialog_changed(buf_T *buf, bool checkall) dialog_msg((char *)buff, _("Save changes to \"%s\"?"), buf->b_fname); if (checkall) { - ret = vim_dialog_yesnoallcancel(VIM_QUESTION, NULL, (char_u *)buff, 1); + ret = vim_dialog_yesnoallcancel(VIM_QUESTION, NULL, buff, 1); } else { - ret = vim_dialog_yesnocancel(VIM_QUESTION, NULL, (char_u *)buff, 1); + ret = vim_dialog_yesnocancel(VIM_QUESTION, NULL, buff, 1); } if (ret == VIM_YES) { @@ -252,7 +252,7 @@ bool dialog_close_terminal(buf_T *buf) dialog_msg(buff, _("Close \"%s\"?"), (buf->b_fname != NULL) ? buf->b_fname : "?"); - int ret = vim_dialog_yesnocancel(VIM_QUESTION, NULL, (char_u *)buff, 1); + int ret = vim_dialog_yesnocancel(VIM_QUESTION, NULL, buff, 1); return ret == VIM_YES; } -- cgit From 3ff46544c9872b4161fd098569c30b55fe3abd36 Mon Sep 17 00:00:00 2001 From: Dundar Göc Date: Fri, 26 Aug 2022 23:11:25 +0200 Subject: refactor: replace char_u with char Work on https://github.com/neovim/neovim/issues/459 --- src/nvim/ex_cmds2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/ex_cmds2.c') diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index e551cbee0b..1248251556 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -703,7 +703,7 @@ void ex_compiler(exarg_T *eap) 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; + size_t bufsize = strlen(eap->arg) + 14; buf = xmalloc(bufsize); if (eap->forceit) { // ":compiler! {name}" sets global options -- cgit From 66360675cf4d091b7460e4a8e1435c13216c1929 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Sun, 11 Sep 2022 17:12:44 +0200 Subject: build: allow IWYU to fix includes for all .c files Allow Include What You Use to remove unnecessary includes and only include what is necessary. This helps with reducing compilation times and makes it easier to visualise which dependencies are actually required. Work on https://github.com/neovim/neovim/issues/549, but doesn't close it since this only works fully for .c files and not headers. --- src/nvim/ex_cmds2.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'src/nvim/ex_cmds2.c') diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index 1248251556..b6489e97b2 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -6,9 +6,9 @@ /// Some more functions for command line commands #include -#include #include #include +#include #include #include "nvim/arglist.h" @@ -16,30 +16,33 @@ #include "nvim/autocmd.h" #include "nvim/buffer.h" #include "nvim/change.h" -#include "nvim/charset.h" +#include "nvim/channel.h" #include "nvim/eval.h" +#include "nvim/eval/typval.h" +#include "nvim/eval/typval_defs.h" #include "nvim/eval/vars.h" #include "nvim/ex_cmds.h" #include "nvim/ex_cmds2.h" +#include "nvim/ex_cmds_defs.h" #include "nvim/ex_docmd.h" -#include "nvim/ex_eval.h" #include "nvim/ex_getln.h" #include "nvim/fileio.h" +#include "nvim/gettext.h" #include "nvim/globals.h" +#include "nvim/highlight_defs.h" +#include "nvim/macros.h" #include "nvim/mark.h" -#include "nvim/mbyte.h" +#include "nvim/memline_defs.h" #include "nvim/memory.h" #include "nvim/message.h" #include "nvim/move.h" #include "nvim/normal.h" -#include "nvim/ops.h" #include "nvim/option.h" -#include "nvim/os/fs_defs.h" -#include "nvim/os_unix.h" +#include "nvim/os/os_defs.h" #include "nvim/path.h" +#include "nvim/pos.h" #include "nvim/quickfix.h" #include "nvim/runtime.h" -#include "nvim/strings.h" #include "nvim/undo.h" #include "nvim/vim.h" #include "nvim/window.h" -- cgit From 3173d07564e7cdf0834099a379f0faf480c76224 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 29 Nov 2022 18:20:11 +0800 Subject: vim-patch:9.0.0965: using one window for executing autocommands is insufficient Problem: Using one window for executing autocommands is insufficient. Solution: Use up to five windows for executing autocommands. https://github.com/vim/vim/commit/e76062c078debed0df818f70e4db14ad7a7cb53a N/A patches for version.c: vim-patch:9.0.0966: some compilers don't allow a declaration after a label Problem: Some compilers don't allow a declaration after a label. Solution: Move the declaration to the start of the block. (John Marriott) https://github.com/vim/vim/commit/f86490ed4fdab213a28f667abd055c023a73d645 Co-authored-by: Bram Moolenaar --- src/nvim/ex_cmds2.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/nvim/ex_cmds2.c') diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index b6489e97b2..d3c0c417e1 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -683,8 +683,10 @@ void ex_listdo(exarg_T *eap) curbuf); } else { aucmd_prepbuf(&aco, buf); - apply_autocmds(EVENT_SYNTAX, buf->b_p_syn, buf->b_fname, true, buf); - aucmd_restbuf(&aco); + if (curbuf == buf) { + apply_autocmds(EVENT_SYNTAX, buf->b_p_syn, buf->b_fname, true, buf); + aucmd_restbuf(&aco); + } } // start over, in case autocommands messed things up. -- cgit From 1145a9b2485a4e5072cffe28a958da983cd59e84 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 2 Dec 2022 20:39:24 +0800 Subject: feat(aucmd_win): allow crazy things with hidden buffers (#21250) Problem: Crash when doing crazy things with hidden buffers. Solution: Dynamically allocate the list of autocommand windows. --- src/nvim/ex_cmds2.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/nvim/ex_cmds2.c') diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index d3c0c417e1..b6489e97b2 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -683,10 +683,8 @@ void ex_listdo(exarg_T *eap) curbuf); } else { aucmd_prepbuf(&aco, buf); - if (curbuf == buf) { - apply_autocmds(EVENT_SYNTAX, buf->b_p_syn, buf->b_fname, true, buf); - aucmd_restbuf(&aco); - } + apply_autocmds(EVENT_SYNTAX, buf->b_p_syn, buf->b_fname, true, buf); + aucmd_restbuf(&aco); } // start over, in case autocommands messed things up. -- cgit From 99cf111289bfcd14981255e805da43bac5139141 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 31 Dec 2022 06:41:23 +0800 Subject: vim-patch:9.0.1115: code is indented more than needed (#21598) Problem: Code is indented more than needed. Solution: Use an early return to reduce indenting. (Yegappan Lakshmanan, closes vim/vim#11758) https://github.com/vim/vim/commit/ed0c1d5d4b30d03b26ff08841f6da2ddf44025a7 Co-authored-by: Yegappan Lakshmanan --- src/nvim/ex_cmds2.c | 153 ++++++++++++++++++++++++++-------------------------- 1 file changed, 78 insertions(+), 75 deletions(-) (limited to 'src/nvim/ex_cmds2.c') diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index b6489e97b2..7020747cf6 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -705,54 +705,56 @@ void ex_compiler(exarg_T *eap) // List all compiler scripts. do_cmdline_cmd("echo globpath(&rtp, 'compiler/*.vim')"); // NOLINT do_cmdline_cmd("echo globpath(&rtp, 'compiler/*.lua')"); // NOLINT + return; + } + + size_t bufsize = strlen(eap->arg) + 14; + buf = xmalloc(bufsize); + + if (eap->forceit) { + // ":compiler! {name}" sets global options + do_cmdline_cmd("command -nargs=* CompilerSet set "); } else { - size_t bufsize = strlen(eap->arg) + 14; - buf = xmalloc(bufsize); - if (eap->forceit) { - // ":compiler! {name}" sets global options - do_cmdline_cmd("command -nargs=* CompilerSet set "); - } else { - // ":compiler! {name}" sets local options. - // To remain backwards compatible "current_compiler" is always - // used. A user's compiler plugin may set it, the distributed - // plugin will then skip the settings. Afterwards set - // "b:current_compiler" and restore "current_compiler". - // Explicitly prepend "g:" to make it work in a function. - old_cur_comp = (char *)get_var_value("g:current_compiler"); - if (old_cur_comp != NULL) { - old_cur_comp = xstrdup(old_cur_comp); - } - do_cmdline_cmd("command -nargs=* -keepscript CompilerSet setlocal "); + // ":compiler! {name}" sets local options. + // To remain backwards compatible "current_compiler" is always + // used. A user's compiler plugin may set it, the distributed + // plugin will then skip the settings. Afterwards set + // "b:current_compiler" and restore "current_compiler". + // Explicitly prepend "g:" to make it work in a function. + old_cur_comp = (char *)get_var_value("g:current_compiler"); + if (old_cur_comp != NULL) { + old_cur_comp = xstrdup(old_cur_comp); } - do_unlet(S_LEN("g:current_compiler"), true); - do_unlet(S_LEN("b:current_compiler"), true); + do_cmdline_cmd("command -nargs=* -keepscript CompilerSet setlocal "); + } + do_unlet(S_LEN("g:current_compiler"), true); + do_unlet(S_LEN("b:current_compiler"), true); - snprintf(buf, bufsize, "compiler/%s.vim", eap->arg); + snprintf(buf, bufsize, "compiler/%s.vim", eap->arg); + if (source_runtime(buf, DIP_ALL) == FAIL) { + // Try lua compiler + snprintf(buf, bufsize, "compiler/%s.lua", eap->arg); if (source_runtime(buf, DIP_ALL) == FAIL) { - // Try lua compiler - snprintf(buf, bufsize, "compiler/%s.lua", eap->arg); - if (source_runtime(buf, DIP_ALL) == FAIL) { - semsg(_("E666: compiler not supported: %s"), eap->arg); - } + semsg(_("E666: compiler not supported: %s"), eap->arg); } - xfree(buf); + } + xfree(buf); - do_cmdline_cmd(":delcommand CompilerSet"); + do_cmdline_cmd(":delcommand CompilerSet"); - // Set "b:current_compiler" from "current_compiler". - p = (char *)get_var_value("g:current_compiler"); - if (p != NULL) { - set_internal_string_var("b:current_compiler", p); - } + // Set "b:current_compiler" from "current_compiler". + p = (char *)get_var_value("g:current_compiler"); + if (p != NULL) { + set_internal_string_var("b:current_compiler", p); + } - // Restore "current_compiler" for ":compiler {name}". - if (!eap->forceit) { - if (old_cur_comp != NULL) { - set_internal_string_var("g:current_compiler", old_cur_comp); - xfree(old_cur_comp); - } else { - do_unlet(S_LEN("g:current_compiler"), true); - } + // Restore "current_compiler" for ":compiler {name}". + if (!eap->forceit) { + if (old_cur_comp != NULL) { + set_internal_string_var("g:current_compiler", old_cur_comp); + xfree(old_cur_comp); + } else { + do_unlet(S_LEN("g:current_compiler"), true); } } } @@ -847,45 +849,46 @@ void ex_drop(exarg_T *eap) // edited in a window yet. It's like ":tab all" but without closing // windows or tabs. ex_all(eap); - } else { - // ":drop file ...": Edit the first argument. Jump to an existing - // window if possible, edit in current window if the current buffer - // can be abandoned, otherwise open a new window. - buf = buflist_findnr(ARGLIST[0].ae_fnum); + return; + } - FOR_ALL_TAB_WINDOWS(tp, wp) { - if (wp->w_buffer == buf) { - goto_tabpage_win(tp, wp); - curwin->w_arg_idx = 0; - if (!bufIsChanged(curbuf)) { - const int save_ar = curbuf->b_p_ar; - - // reload the file if it is newer - curbuf->b_p_ar = 1; - buf_check_timestamp(curbuf); - curbuf->b_p_ar = save_ar; - } - return; + // ":drop file ...": Edit the first argument. Jump to an existing + // window if possible, edit in current window if the current buffer + // can be abandoned, otherwise open a new window. + buf = buflist_findnr(ARGLIST[0].ae_fnum); + + FOR_ALL_TAB_WINDOWS(tp, wp) { + if (wp->w_buffer == buf) { + goto_tabpage_win(tp, wp); + curwin->w_arg_idx = 0; + if (!bufIsChanged(curbuf)) { + const int save_ar = curbuf->b_p_ar; + + // reload the file if it is newer + curbuf->b_p_ar = 1; + buf_check_timestamp(curbuf); + curbuf->b_p_ar = save_ar; } + return; } + } - // Check whether the current buffer is changed. If so, we will need - // to split the current window or data could be lost. - // Skip the check if the 'hidden' option is set, as in this case the - // buffer won't be lost. - if (!buf_hide(curbuf)) { - emsg_off++; - split = check_changed(curbuf, CCGD_AW | CCGD_EXCMD); - emsg_off--; - } + // Check whether the current buffer is changed. If so, we will need + // to split the current window or data could be lost. + // Skip the check if the 'hidden' option is set, as in this case the + // buffer won't be lost. + if (!buf_hide(curbuf)) { + emsg_off++; + split = check_changed(curbuf, CCGD_AW | CCGD_EXCMD); + emsg_off--; + } - // Fake a ":sfirst" or ":first" command edit the first argument. - if (split) { - eap->cmdidx = CMD_sfirst; - eap->cmd[0] = 's'; - } else { - eap->cmdidx = CMD_first; - } - ex_rewind(eap); + // Fake a ":sfirst" or ":first" command edit the first argument. + if (split) { + eap->cmdidx = CMD_sfirst; + eap->cmd[0] = 's'; + } else { + eap->cmdidx = CMD_first; } + ex_rewind(eap); } -- cgit From f2141de9e462ed8976b2a59337c32a0fcba2a11d Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Fri, 13 Jan 2023 00:35:39 +0100 Subject: refactor: replace char_u with char 20 (#21714) refactor: replace char_u with char Work on https://github.com/neovim/neovim/issues/459 --- src/nvim/ex_cmds2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/ex_cmds2.c') diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index 7020747cf6..d08823bc30 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -721,7 +721,7 @@ void ex_compiler(exarg_T *eap) // plugin will then skip the settings. Afterwards set // "b:current_compiler" and restore "current_compiler". // Explicitly prepend "g:" to make it work in a function. - old_cur_comp = (char *)get_var_value("g:current_compiler"); + old_cur_comp = get_var_value("g:current_compiler"); if (old_cur_comp != NULL) { old_cur_comp = xstrdup(old_cur_comp); } @@ -743,7 +743,7 @@ void ex_compiler(exarg_T *eap) do_cmdline_cmd(":delcommand CompilerSet"); // Set "b:current_compiler" from "current_compiler". - p = (char *)get_var_value("g:current_compiler"); + p = get_var_value("g:current_compiler"); if (p != NULL) { set_internal_string_var("b:current_compiler", p); } -- cgit