From 78658ef3834baf7d202eb16a8778813e08e58412 Mon Sep 17 00:00:00 2001 From: Famiu Haque Date: Wed, 10 Aug 2022 16:37:59 +0600 Subject: fix(api): `vim.cmd.make` crashes when argument count isn't 1 (#19701) Closes #19696 --- src/nvim/api/command.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/nvim/api') diff --git a/src/nvim/api/command.c b/src/nvim/api/command.c index bc766ff39c..fc1f6a04f2 100644 --- a/src/nvim/api/command.c +++ b/src/nvim/api/command.c @@ -819,9 +819,12 @@ static void build_cmdline_str(char **cmdlinep, exarg_T *eap, CmdParseInfo *cmdin char *p = replace_makeprg(eap, eap->arg, cmdlinep); if (p != eap->arg) { // If replace_makeprg modified the cmdline string, correct the argument pointers. - assert(argc == 1); eap->arg = p; - eap->args[0] = p; + // We can only know the position of the first argument because the argument list can be used + // multiple times in makeprg / grepprg. + if (argc >= 1) { + eap->args[0] = p; + } } } -- cgit From 94c317647845b92d675548a481f664a6a1808426 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 11 Aug 2022 15:44:55 +0800 Subject: refactor: use CLEAR_FIELD and CLEAR_POINTER macros (#19709) vim-patch:8.2.0559: clearing a struct is verbose Problem: Clearing a struct is verbose. Solution: Define and use CLEAR_FIELD() and CLEAR_POINTER(). https://github.com/vim/vim/commit/a80faa8930ed5a554beeb2727762538873135e83 --- src/nvim/api/command.c | 4 ++-- src/nvim/api/ui.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/nvim/api') diff --git a/src/nvim/api/command.c b/src/nvim/api/command.c index fc1f6a04f2..d264237e37 100644 --- a/src/nvim/api/command.c +++ b/src/nvim/api/command.c @@ -300,10 +300,10 @@ String nvim_cmd(uint64_t channel_id, Dict(cmd) *cmd, Dict(cmd_opts) *opts, Error FUNC_API_SINCE(10) { exarg_T ea; - memset(&ea, 0, sizeof(ea)); + CLEAR_FIELD(ea); CmdParseInfo cmdinfo; - memset(&cmdinfo, 0, sizeof(cmdinfo)); + CLEAR_FIELD(cmdinfo); char *cmdline = NULL; char *cmdname = NULL; diff --git a/src/nvim/api/ui.c b/src/nvim/api/ui.c index 6239e414a7..9cd4c97508 100644 --- a/src/nvim/api/ui.c +++ b/src/nvim/api/ui.c @@ -224,7 +224,7 @@ void nvim_ui_attach(uint64_t channel_id, Integer width, Integer height, Dictiona ui->event = remote_ui_event; ui->inspect = remote_ui_inspect; - memset(ui->ui_ext, 0, sizeof(ui->ui_ext)); + CLEAR_FIELD(ui->ui_ext); for (size_t i = 0; i < options.size; i++) { ui_set_option(ui, true, options.items[i].key, options.items[i].value, err); -- cgit From a27756cc2463139343aa3c214ad20908d42f67a6 Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Thu, 11 Aug 2022 17:26:17 +0100 Subject: fix(signs): priority of extmark signs (#19718) --- src/nvim/api/extmark.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/nvim/api') diff --git a/src/nvim/api/extmark.c b/src/nvim/api/extmark.c index da1b6beeda..c36f127507 100644 --- a/src/nvim/api/extmark.c +++ b/src/nvim/api/extmark.c @@ -441,8 +441,9 @@ Array nvim_buf_get_extmarks(Buffer buffer, Integer ns_id, Object start, Object e /// the extmark end position (if it exists) will be shifted /// in when new text is inserted (true for right, false /// for left). Defaults to false. -/// - priority: a priority value for the highlight group. For -/// example treesitter highlighting uses a value of 100. +/// - priority: a priority value for the highlight group or sign +/// attribute. For example treesitter highlighting uses a +/// value of 100. /// - strict: boolean that indicates extmark should not be placed /// if the line or column value is past the end of the /// buffer or end of the line respectively. Defaults to true. -- cgit From f79773a3b4b3ce5a3b37652a72b12089880f32a4 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 12 Aug 2022 19:16:24 +0800 Subject: refactor: move non-symbols in ex_eval.h to ex_eval_defs.h (#19739) This avoids including ex_eval.h in any other header, thus preventing future circular includes. --- src/nvim/api/command.c | 1 + src/nvim/api/private/helpers.c | 5 +++-- src/nvim/api/private/helpers.h | 10 +++++----- src/nvim/api/vim.c | 1 + 4 files changed, 10 insertions(+), 7 deletions(-) (limited to 'src/nvim/api') diff --git a/src/nvim/api/command.c b/src/nvim/api/command.c index d264237e37..e77add6210 100644 --- a/src/nvim/api/command.c +++ b/src/nvim/api/command.c @@ -11,6 +11,7 @@ #include "nvim/api/private/helpers.h" #include "nvim/autocmd.h" #include "nvim/ex_docmd.h" +#include "nvim/ex_eval.h" #include "nvim/lua/executor.h" #include "nvim/ops.h" #include "nvim/regexp.h" diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c index fad75d55be..315df72a53 100644 --- a/src/nvim/api/private/helpers.c +++ b/src/nvim/api/private/helpers.c @@ -19,6 +19,7 @@ #include "nvim/eval.h" #include "nvim/eval/typval.h" #include "nvim/ex_cmds_defs.h" +#include "nvim/ex_eval.h" #include "nvim/extmark.h" #include "nvim/fileio.h" #include "nvim/highlight_group.h" @@ -54,7 +55,7 @@ void try_enter(TryState *const tstate) // save_dbg_stuff()/restore_dbg_stuff(). *tstate = (TryState) { .current_exception = current_exception, - .msg_list = (const struct msglist *const *)msg_list, + .msg_list = (const msglist_T *const *)msg_list, .private_msg_list = NULL, .trylevel = trylevel, .got_int = got_int, @@ -89,7 +90,7 @@ bool try_leave(const TryState *const tstate, Error *const err) assert(msg_list == &tstate->private_msg_list); assert(*msg_list == NULL); assert(current_exception == NULL); - msg_list = (struct msglist **)tstate->msg_list; + msg_list = (msglist_T **)tstate->msg_list; current_exception = tstate->current_exception; trylevel = tstate->trylevel; got_int = tstate->got_int; diff --git a/src/nvim/api/private/helpers.h b/src/nvim/api/private/helpers.h index 1441da853c..4608554448 100644 --- a/src/nvim/api/private/helpers.h +++ b/src/nvim/api/private/helpers.h @@ -3,7 +3,7 @@ #include "nvim/api/private/defs.h" #include "nvim/decoration.h" -#include "nvim/ex_eval.h" +#include "nvim/ex_eval_defs.h" #include "nvim/getchar.h" #include "nvim/lib/kvec.h" #include "nvim/memory.h" @@ -130,8 +130,8 @@ EXTERN PMap(handle_T) tabpage_handles INIT(= MAP_INIT); /// processed and that “other VimL code” must not be affected. typedef struct { except_T *current_exception; - struct msglist *private_msg_list; - const struct msglist *const *msg_list; + msglist_T *private_msg_list; + const msglist_T *const *msg_list; int trylevel; int got_int; int need_rethrow; @@ -144,8 +144,8 @@ typedef struct { // TODO(bfredl): prepare error-handling at "top level" (nv_event). #define TRY_WRAP(code) \ do { \ - struct msglist **saved_msg_list = msg_list; \ - struct msglist *private_msg_list; \ + msglist_T **saved_msg_list = msg_list; \ + msglist_T *private_msg_list; \ msg_list = &private_msg_list; \ private_msg_list = NULL; \ code \ diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index e2f58dba62..2842f3a43b 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -30,6 +30,7 @@ #include "nvim/ex_cmds2.h" #include "nvim/ex_cmds_defs.h" #include "nvim/ex_docmd.h" +#include "nvim/ex_eval.h" #include "nvim/file_search.h" #include "nvim/fileio.h" #include "nvim/getchar.h" -- cgit From 342d18b91ec176c5e3aa6d32d439d01e6ac88ee6 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 12 Aug 2022 21:16:28 +0800 Subject: refactor: remove some unused includes (#19740) Mostly avoids including eval.h, ex_cmds2.h and ex_docmd.h in other headers. --- src/nvim/api/vim.c | 2 +- src/nvim/api/vimscript.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'src/nvim/api') diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 2842f3a43b..2622f4bb81 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -27,7 +27,6 @@ #include "nvim/eval.h" #include "nvim/eval/typval.h" #include "nvim/eval/userfunc.h" -#include "nvim/ex_cmds2.h" #include "nvim/ex_cmds_defs.h" #include "nvim/ex_docmd.h" #include "nvim/ex_eval.h" @@ -54,6 +53,7 @@ #include "nvim/os/input.h" #include "nvim/os/process.h" #include "nvim/popupmnu.h" +#include "nvim/runtime.h" #include "nvim/screen.h" #include "nvim/state.h" #include "nvim/types.h" diff --git a/src/nvim/api/vimscript.c b/src/nvim/api/vimscript.c index 478e146781..3b25e3aa38 100644 --- a/src/nvim/api/vimscript.c +++ b/src/nvim/api/vimscript.c @@ -14,8 +14,9 @@ #include "nvim/eval.h" #include "nvim/eval/typval.h" #include "nvim/eval/userfunc.h" -#include "nvim/ex_cmds2.h" +#include "nvim/ex_docmd.h" #include "nvim/ops.h" +#include "nvim/runtime.h" #include "nvim/strings.h" #include "nvim/vim.h" #include "nvim/viml/parser/expressions.h" -- cgit From 6f14c5d2ddbefea51920762769eec217d19a9ed9 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 13 Aug 2022 08:59:11 +0800 Subject: refactor: remove some unused includes (#19747) - Remove autocmd.h from fileio.h - Remove normal.h from main.h - Move bufinfo_T from undo_defs.h to undo.c --- src/nvim/api/autocmd.c | 2 +- src/nvim/api/private/helpers.c | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'src/nvim/api') diff --git a/src/nvim/api/autocmd.c b/src/nvim/api/autocmd.c index bf6402f938..79ae7994f7 100644 --- a/src/nvim/api/autocmd.c +++ b/src/nvim/api/autocmd.c @@ -9,9 +9,9 @@ #include "nvim/api/private/defs.h" #include "nvim/api/private/helpers.h" #include "nvim/ascii.h" +#include "nvim/autocmd.h" #include "nvim/buffer.h" #include "nvim/eval/typval.h" -#include "nvim/fileio.h" #include "nvim/lua/executor.h" #ifdef INCLUDE_GENERATED_DECLARATIONS diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c index 315df72a53..c466fc53e1 100644 --- a/src/nvim/api/private/helpers.c +++ b/src/nvim/api/private/helpers.c @@ -21,7 +21,6 @@ #include "nvim/ex_cmds_defs.h" #include "nvim/ex_eval.h" #include "nvim/extmark.h" -#include "nvim/fileio.h" #include "nvim/highlight_group.h" #include "nvim/lib/kvec.h" #include "nvim/lua/executor.h" -- cgit From 33f4ba7379b5ad1670f9168dd98e3031780776f1 Mon Sep 17 00:00:00 2001 From: bfredl Date: Sat, 13 Aug 2022 10:45:21 +0200 Subject: fix(winbar): do not always assume cursor is valid. fixes #19458 --- src/nvim/api/win_config.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/api') diff --git a/src/nvim/api/win_config.c b/src/nvim/api/win_config.c index 969643eeef..a153f746b6 100644 --- a/src/nvim/api/win_config.c +++ b/src/nvim/api/win_config.c @@ -167,7 +167,7 @@ Window nvim_open_win(Buffer buffer, Boolean enter, Dict(float_config) *config, E if (fconfig.style == kWinStyleMinimal) { win_set_minimal_style(wp); - didset_window_options(wp); + didset_window_options(wp, true); } return wp->handle; } @@ -209,7 +209,7 @@ void nvim_win_set_config(Window window, Dict(float_config) *config, Error *err) } if (fconfig.style == kWinStyleMinimal) { win_set_minimal_style(win); - didset_window_options(win); + didset_window_options(win, true); } } -- cgit From 03fddfd92887bbac920d80cd9e04f28f32843f5d Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 16 Aug 2022 17:30:39 +0800 Subject: fix(api): nvim_exec and nvim_cmd restore msg_col when capturing output (#19789) This matches the code in execute_common(), preventing messages after the API call from being printed at the wrong column. --- src/nvim/api/command.c | 4 ++++ src/nvim/api/vimscript.c | 4 ++++ 2 files changed, 8 insertions(+) (limited to 'src/nvim/api') diff --git a/src/nvim/api/command.c b/src/nvim/api/command.c index e77add6210..1323fc347b 100644 --- a/src/nvim/api/command.c +++ b/src/nvim/api/command.c @@ -626,6 +626,7 @@ String nvim_cmd(uint64_t channel_id, Dict(cmd) *cmd, Dict(cmd_opts) *opts, Error garray_T capture_local; const int save_msg_silent = msg_silent; garray_T * const save_capture_ga = capture_ga; + const int save_msg_col = msg_col; if (output) { ga_init(&capture_local, 1, 80); @@ -636,6 +637,7 @@ String nvim_cmd(uint64_t channel_id, Dict(cmd) *cmd, Dict(cmd_opts) *opts, Error try_start(); if (output) { msg_silent++; + msg_col = 0; // prevent leading spaces } WITH_SCRIPT_CONTEXT(channel_id, { @@ -645,6 +647,8 @@ String nvim_cmd(uint64_t channel_id, Dict(cmd) *cmd, Dict(cmd_opts) *opts, Error if (output) { capture_ga = save_capture_ga; msg_silent = save_msg_silent; + // Put msg_col back where it was, since nothing should have been written. + msg_col = save_msg_col; } try_end(err); diff --git a/src/nvim/api/vimscript.c b/src/nvim/api/vimscript.c index 3b25e3aa38..a28bfd2ab9 100644 --- a/src/nvim/api/vimscript.c +++ b/src/nvim/api/vimscript.c @@ -49,6 +49,7 @@ String nvim_exec(uint64_t channel_id, String src, Boolean output, Error *err) { const int save_msg_silent = msg_silent; garray_T *const save_capture_ga = capture_ga; + const int save_msg_col = msg_col; garray_T capture_local; if (output) { ga_init(&capture_local, 1, 80); @@ -58,6 +59,7 @@ String nvim_exec(uint64_t channel_id, String src, Boolean output, Error *err) try_start(); if (output) { msg_silent++; + msg_col = 0; // prevent leading spaces } const sctx_T save_current_sctx = api_set_sctx(channel_id); @@ -66,6 +68,8 @@ String nvim_exec(uint64_t channel_id, String src, Boolean output, Error *err) if (output) { capture_ga = save_capture_ga; msg_silent = save_msg_silent; + // Put msg_col back where it was, since nothing should have been written. + msg_col = save_msg_col; } current_sctx = save_current_sctx; -- cgit From f7cfca49d6f1380b2ec0b0f7723ea308d0810857 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 17 Aug 2022 22:18:34 +0800 Subject: refactor: remove some unused includes (#19820) Replace grid.h in screen.h and screen.h in buffer.h with grid_defs.h --- src/nvim/api/buffer.c | 1 + src/nvim/api/ui.c | 2 +- src/nvim/api/vim.c | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) (limited to 'src/nvim/api') diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c index d3895d31cf..9bb3c680aa 100644 --- a/src/nvim/api/buffer.c +++ b/src/nvim/api/buffer.c @@ -28,6 +28,7 @@ #include "nvim/memory.h" #include "nvim/move.h" #include "nvim/ops.h" +#include "nvim/screen.h" #include "nvim/undo.h" #include "nvim/vim.h" #include "nvim/window.h" diff --git a/src/nvim/api/ui.c b/src/nvim/api/ui.c index 9cd4c97508..84cc77d8de 100644 --- a/src/nvim/api/ui.c +++ b/src/nvim/api/ui.c @@ -11,6 +11,7 @@ #include "nvim/api/ui.h" #include "nvim/channel.h" #include "nvim/cursor_shape.h" +#include "nvim/grid.h" #include "nvim/highlight.h" #include "nvim/map.h" #include "nvim/memory.h" @@ -18,7 +19,6 @@ #include "nvim/msgpack_rpc/helpers.h" #include "nvim/option.h" #include "nvim/popupmnu.h" -#include "nvim/screen.h" #include "nvim/ui.h" #include "nvim/vim.h" #include "nvim/window.h" diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 2622f4bb81..3f9730c569 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -34,6 +34,7 @@ #include "nvim/fileio.h" #include "nvim/getchar.h" #include "nvim/globals.h" +#include "nvim/grid.h" #include "nvim/highlight.h" #include "nvim/highlight_defs.h" #include "nvim/highlight_group.h" -- cgit From d879331b0dee66cb106b5bea9efc2f920caf9abd Mon Sep 17 00:00:00 2001 From: bfredl Date: Mon, 25 Jul 2022 10:16:33 +0200 Subject: feat(ui): allow to set the highlight namespace per window - reimplement 'winhl' in terms of highlight namespaces - check for EOF in screen tests (to indicate a likely crash) --- src/nvim/api/extmark.c | 2 ++ src/nvim/api/keysets.lua | 3 +-- src/nvim/api/vim.c | 61 +++++++++++++++++++++++------------------------- src/nvim/api/window.c | 25 ++++++++++++++++++++ 4 files changed, 57 insertions(+), 34 deletions(-) (limited to 'src/nvim/api') diff --git a/src/nvim/api/extmark.c b/src/nvim/api/extmark.c index c36f127507..b8295601c1 100644 --- a/src/nvim/api/extmark.c +++ b/src/nvim/api/extmark.c @@ -1031,6 +1031,8 @@ void nvim_set_decoration_provider(Integer ns_id, DictionaryOf(LuaRef) opts, Erro } p->active = true; + p->hl_valid++; + p->hl_cached = false; return; error: decor_provider_clear(p); diff --git a/src/nvim/api/keysets.lua b/src/nvim/api/keysets.lua index 4f4ac40ce9..6fad52ba75 100644 --- a/src/nvim/api/keysets.lua +++ b/src/nvim/api/keysets.lua @@ -104,7 +104,6 @@ return { "reverse"; "nocombine"; "default"; - "global"; "cterm"; "foreground"; "fg"; "background"; "bg"; @@ -112,9 +111,9 @@ return { "ctermbg"; "special"; "sp"; "link"; + "global_link"; "fallback"; "blend"; - "temp"; }; highlight_cterm = { "bold"; diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 3f9730c569..25f6e822b3 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -93,7 +93,6 @@ Dictionary nvim_get_hl_by_name(String name, Boolean rgb, Error *err) } /// Gets a highlight definition by id. |hlID()| -/// /// @param hl_id Highlight id as returned by |hlID()| /// @param rgb Export RGB colors /// @param[out] err Error details, if any @@ -182,35 +181,38 @@ void nvim_set_hl(Integer ns_id, String name, Dict(highlight) *val, Error *err) } } -/// Set active namespace for highlights. -/// -/// NB: this function can be called from async contexts, but the -/// semantics are not yet well-defined. To start with -/// |nvim_set_decoration_provider| on_win and on_line callbacks -/// are explicitly allowed to change the namespace during a redraw cycle. +/// Set active namespace for highlights. This can be set for a single window, +/// see |nvim_win_set_hl_ns|. /// -/// @param ns_id the namespace to activate +/// @param ns_id the namespace to use /// @param[out] err Error details, if any -void nvim__set_hl_ns(Integer ns_id, Error *err) - FUNC_API_FAST +void nvim_set_hl_ns(Integer ns_id, Error *err) + FUNC_API_SINCE(10) { - if (ns_id >= 0) { - ns_hl_active = (NS)ns_id; + if (ns_id < 0) { + api_set_error(err, kErrorTypeValidation, "no such namespace"); + return; } - // TODO(bfredl): this is a little bit hackish. Eventually we want a standard - // event path for redraws caused by "fast" events. This could tie in with - // better throttling of async events causing redraws, such as non-batched - // nvim_buf_set_extmark calls from async contexts. - if (!provider_active && !ns_hl_changed && must_redraw < NOT_VALID) { - multiqueue_put(main_loop.events, on_redraw_event, 0); - } - ns_hl_changed = true; + ns_hl_global = (NS)ns_id; + hl_check_ns(); + redraw_all_later(NOT_VALID); } -static void on_redraw_event(void **argv) +/// Set active namespace for highlights while redrawing. +/// +/// This function meant to be called while redrawing, primarily from +/// |nvim_set_decoration_provider| on_win and on_line callbacks, which +/// are allowed to change the namespace during a redraw cycle. +/// +/// @param ns_id the namespace to activate +/// @param[out] err Error details, if any +void nvim_set_hl_ns_fast(Integer ns_id, Error *err) + FUNC_API_SINCE(10) + FUNC_API_FAST { - redraw_all_later(NOT_VALID); + ns_hl_fast = (NS)ns_id; + hl_check_ns(); } /// Sends input-keys to Nvim, subject to various quirks controlled by `mode` @@ -480,7 +482,7 @@ Object nvim_notify(String msg, Integer log_level, Dictionary opts, Error *err) ADD_C(args, INTEGER_OBJ(log_level)); ADD_C(args, DICTIONARY_OBJ(opts)); - return nlua_exec(STATIC_CSTR_AS_STRING("return vim.notify(...)"), args, err); + return NLUA_EXEC_STATIC("return vim.notify(...)", args, err); } /// Calculates the number of display cells occupied by `text`. @@ -1835,11 +1837,9 @@ Array nvim_get_proc_children(Integer pid, Error *err) if (rv == 2) { // syscall failed (possibly because of kernel options), try shelling out. DLOG("fallback to vim._os_proc_children()"); - Array a = ARRAY_DICT_INIT; + MAXSIZE_TEMP_ARRAY(a, 1); ADD(a, INTEGER_OBJ(pid)); - String s = STATIC_CSTR_AS_STRING("return vim._os_proc_children(...)"); - Object o = nlua_exec(s, a, err); - api_free_array(a); + Object o = NLUA_EXEC_STATIC("return vim._os_proc_children(...)", a, err); if (o.type == kObjectTypeArray) { rvobj = o.data.array; } else if (!ERROR_SET(err)) { @@ -1880,12 +1880,9 @@ Object nvim_get_proc(Integer pid, Error *err) } #else // Cross-platform process info APIs are miserable, so use `ps` instead. - Array a = ARRAY_DICT_INIT; + MAXSIZE_TEMP_ARRAY(a, 1); ADD(a, INTEGER_OBJ(pid)); - String s = cstr_to_string("return vim._os_proc_info(select(1, ...))"); - Object o = nlua_exec(s, a, err); - api_free_string(s); - api_free_array(a); + Object o = NLUA_EXEC_STATIC("return vim._os_proc_info(...)", a, err); if (o.type == kObjectTypeArray && o.data.array.size == 0) { return NIL; // Process not found. } else if (o.type == kObjectTypeDictionary) { diff --git a/src/nvim/api/window.c b/src/nvim/api/window.c index 5a4ff70257..d0a2ff766e 100644 --- a/src/nvim/api/window.c +++ b/src/nvim/api/window.c @@ -426,3 +426,28 @@ Object nvim_win_call(Window window, LuaRef fun, Error *err) try_end(err); return res; } + +/// Set highlight namespace for a window. This will use highlights defined in +/// this namespace, but fall back to global highlights (ns=0) when missing. +/// +/// This takes predecence over the 'winhighlight' option. +/// +/// @param ns_id the namespace to use +/// @param[out] err Error details, if any +void nvim_win_set_hl_ns(Window window, Integer ns_id, Error *err) + FUNC_API_SINCE(10) +{ + win_T *win = find_window_by_handle(window, err); + if (!win) { + return; + } + + // -1 is allowed as inherit global namespace + if (ns_id < -1) { + api_set_error(err, kErrorTypeValidation, "no such namespace"); + } + + win->w_ns_hl = (NS)ns_id; + win->w_hl_needs_update = true; + redraw_later(win, NOT_VALID); +} -- cgit From fbcce2b2ca781fa2133e5d1c85d1eb4ea91a06ee Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 18 Aug 2022 17:06:39 +0800 Subject: vim-patch:8.1.2082: rename popupmnu.* to popupmenu.* (#19829) vim-patch:8.1.2082: some files have a weird name to fit in 8.3 characters Problem: Some files have a weird name to fit in 8.3 characters. Solution: Use a nicer names. https://github.com/vim/vim/commit/30e8e73506e4522ef4aebf7d525c0e6ffe8805fd --- src/nvim/api/ui.c | 2 +- src/nvim/api/vim.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/api') diff --git a/src/nvim/api/ui.c b/src/nvim/api/ui.c index 84cc77d8de..6f7bfa244a 100644 --- a/src/nvim/api/ui.c +++ b/src/nvim/api/ui.c @@ -18,7 +18,7 @@ #include "nvim/msgpack_rpc/channel.h" #include "nvim/msgpack_rpc/helpers.h" #include "nvim/option.h" -#include "nvim/popupmnu.h" +#include "nvim/popupmenu.h" #include "nvim/ui.h" #include "nvim/vim.h" #include "nvim/window.h" diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 25f6e822b3..53ffac1474 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -53,7 +53,7 @@ #include "nvim/option.h" #include "nvim/os/input.h" #include "nvim/os/process.h" -#include "nvim/popupmnu.h" +#include "nvim/popupmenu.h" #include "nvim/runtime.h" #include "nvim/screen.h" #include "nvim/state.h" -- cgit From 51063a90df4cc8af4e1111dd50194ae487e8097e Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Tue, 16 Aug 2022 12:27:07 +0100 Subject: vim-patch:8.1.2057: the screen.c file is much too big Problem: The screen.c file is much too big. Solution: Split it in three parts. (Yegappan Lakshmanan, closes vim/vim#4943) https://github.com/vim/vim/commit/7528d1f6b5422750eb778dfb550cfd0b0e540964 This is an approximation vim-patch 8.1.2057. Applying the patch directly isn't feasible since our version of screen.c has diverged too much, however we still introduce drawscreen.c and drawline.c: - screen.c is now a much smaller file used for low level screen functions - drawline.c contains everything needed for win_line() - drawscreen.c contains everything needed for update_screen() Co-authored-by: zeertzjq --- src/nvim/api/buffer.c | 2 +- src/nvim/api/extmark.c | 2 +- src/nvim/api/vim.c | 2 +- src/nvim/api/win_config.c | 2 +- src/nvim/api/window.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/nvim/api') diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c index 9bb3c680aa..5e90e40dd3 100644 --- a/src/nvim/api/buffer.c +++ b/src/nvim/api/buffer.c @@ -18,6 +18,7 @@ #include "nvim/change.h" #include "nvim/cursor.h" #include "nvim/decoration.h" +#include "nvim/drawscreen.h" #include "nvim/ex_cmds.h" #include "nvim/ex_docmd.h" #include "nvim/extmark.h" @@ -28,7 +29,6 @@ #include "nvim/memory.h" #include "nvim/move.h" #include "nvim/ops.h" -#include "nvim/screen.h" #include "nvim/undo.h" #include "nvim/vim.h" #include "nvim/window.h" diff --git a/src/nvim/api/extmark.c b/src/nvim/api/extmark.c index b8295601c1..933aa85530 100644 --- a/src/nvim/api/extmark.c +++ b/src/nvim/api/extmark.c @@ -10,11 +10,11 @@ #include "nvim/api/private/helpers.h" #include "nvim/charset.h" #include "nvim/decoration_provider.h" +#include "nvim/drawscreen.h" #include "nvim/extmark.h" #include "nvim/highlight_group.h" #include "nvim/lua/executor.h" #include "nvim/memline.h" -#include "nvim/screen.h" #ifdef INCLUDE_GENERATED_DECLARATIONS # include "api/extmark.c.generated.h" diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 53ffac1474..e4dc219e9a 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -23,6 +23,7 @@ #include "nvim/context.h" #include "nvim/decoration.h" #include "nvim/decoration_provider.h" +#include "nvim/drawscreen.h" #include "nvim/edit.h" #include "nvim/eval.h" #include "nvim/eval/typval.h" @@ -55,7 +56,6 @@ #include "nvim/os/process.h" #include "nvim/popupmenu.h" #include "nvim/runtime.h" -#include "nvim/screen.h" #include "nvim/state.h" #include "nvim/types.h" #include "nvim/ui.h" diff --git a/src/nvim/api/win_config.c b/src/nvim/api/win_config.c index a153f746b6..6c37df6af8 100644 --- a/src/nvim/api/win_config.c +++ b/src/nvim/api/win_config.c @@ -10,9 +10,9 @@ #include "nvim/api/private/helpers.h" #include "nvim/api/win_config.h" #include "nvim/ascii.h" +#include "nvim/drawscreen.h" #include "nvim/highlight_group.h" #include "nvim/option.h" -#include "nvim/screen.h" #include "nvim/strings.h" #include "nvim/syntax.h" #include "nvim/ui.h" diff --git a/src/nvim/api/window.c b/src/nvim/api/window.c index d0a2ff766e..580dfd8639 100644 --- a/src/nvim/api/window.c +++ b/src/nvim/api/window.c @@ -12,12 +12,12 @@ #include "nvim/ascii.h" #include "nvim/buffer.h" #include "nvim/cursor.h" +#include "nvim/drawscreen.h" #include "nvim/ex_docmd.h" #include "nvim/globals.h" #include "nvim/lua/executor.h" #include "nvim/move.h" #include "nvim/option.h" -#include "nvim/screen.h" #include "nvim/syntax.h" #include "nvim/vim.h" #include "nvim/window.h" -- cgit