From 7784dc9e0d90284b0d9c9cf0833c27d4de22b7f4 Mon Sep 17 00:00:00 2001 From: bfredl Date: Tue, 23 Aug 2022 13:52:09 +0200 Subject: refactor(api): provide a temporary copy solution for nvim_call_atomic Make the copy_object() family accept an optional arena. More than half of the callsites should be refactored to use an arena later anyway. --- src/nvim/context.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/context.c') diff --git a/src/nvim/context.c b/src/nvim/context.c index e3ae9355bf..34692cdf64 100644 --- a/src/nvim/context.c +++ b/src/nvim/context.c @@ -345,7 +345,7 @@ Dictionary ctx_to_dict(Context *ctx) PUT(rv, "jumps", ARRAY_OBJ(sbuf_to_array(ctx->jumps))); PUT(rv, "bufs", ARRAY_OBJ(sbuf_to_array(ctx->bufs))); PUT(rv, "gvars", ARRAY_OBJ(sbuf_to_array(ctx->gvars))); - PUT(rv, "funcs", ARRAY_OBJ(copy_array(ctx->funcs))); + PUT(rv, "funcs", ARRAY_OBJ(copy_array(ctx->funcs, NULL))); return rv; } @@ -381,7 +381,7 @@ int ctx_from_dict(Dictionary dict, Context *ctx) ctx->gvars = array_to_sbuf(item.value.data.array); } else if (strequal(item.key.data, "funcs")) { types |= kCtxFuncs; - ctx->funcs = copy_object(item.value).data.array; + ctx->funcs = copy_object(item.value, NULL).data.array; } } -- cgit From 42e44d6d334bda8b97afe9e34a819ab293e5e10a Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 7 Nov 2022 10:26:54 +0800 Subject: vim-patch:8.2.3751: cannot assign a lambda to an option that takes a function Problem: Cannot assign a lambda to an option that takes a function. Solution: Automatically convert the lambda to a string. (Yegappan Lakshmanan, closes vim/vim#9286) https://github.com/vim/vim/commit/6409553b6e3b4de4e1d72b8ee5445595214581ff Co-authored-by: Yegappan Lakshmanan --- src/nvim/context.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/context.c') diff --git a/src/nvim/context.c b/src/nvim/context.c index 34692cdf64..c765b95733 100644 --- a/src/nvim/context.c +++ b/src/nvim/context.c @@ -131,7 +131,7 @@ bool ctx_restore(Context *ctx, const int flags) } char *op_shada; - get_option_value("shada", NULL, &op_shada, OPT_GLOBAL); + get_option_value("shada", NULL, &op_shada, NULL, OPT_GLOBAL); set_option_value("shada", 0L, "!,'100,%", OPT_GLOBAL); if (flags & kCtxRegs) { -- 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/context.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/nvim/context.c') diff --git a/src/nvim/context.c b/src/nvim/context.c index c765b95733..5ea843e023 100644 --- a/src/nvim/context.c +++ b/src/nvim/context.c @@ -3,16 +3,28 @@ // Context: snapshot of the entire editor state as one big object/map +#include +#include +#include + #include "nvim/api/private/converter.h" #include "nvim/api/private/helpers.h" -#include "nvim/api/vim.h" #include "nvim/api/vimscript.h" #include "nvim/context.h" #include "nvim/eval/encode.h" +#include "nvim/eval/typval.h" +#include "nvim/eval/typval_defs.h" #include "nvim/eval/userfunc.h" #include "nvim/ex_docmd.h" +#include "nvim/gettext.h" +#include "nvim/hashtab.h" +#include "nvim/keycodes.h" +#include "nvim/memory.h" +#include "nvim/message.h" #include "nvim/option.h" #include "nvim/shada.h" +#include "nvim/types.h" +#include "nvim/vim.h" #ifdef INCLUDE_GENERATED_DECLARATIONS # include "context.c.generated.h" -- cgit From bd22585061b66d7f71d4832b4a81e950b3c9d19d 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/context.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/nvim/context.c') diff --git a/src/nvim/context.c b/src/nvim/context.c index 5ea843e023..47e60373bf 100644 --- a/src/nvim/context.c +++ b/src/nvim/context.c @@ -263,12 +263,12 @@ static inline void ctx_save_funcs(Context *ctx, bool scriptonly) Error err = ERROR_INIT; HASHTAB_ITER(func_tbl_get(), hi, { - const char_u *const name = hi->hi_key; + const char *const name = hi->hi_key; bool islambda = (STRNCMP(name, "", 8) == 0); - bool isscript = (name[0] == K_SPECIAL); + bool isscript = ((uint8_t)name[0] == K_SPECIAL); if (!islambda && (!scriptonly || isscript)) { - size_t cmd_len = sizeof("func! ") + STRLEN(name); + size_t cmd_len = sizeof("func! ") + strlen(name); char *cmd = xmalloc(cmd_len); snprintf(cmd, cmd_len, "func! %s", name); String func_body = nvim_exec(VIML_INTERNAL_CALL, cstr_as_string(cmd), -- cgit From 3b96ccf7d35be90e49029dec76344d3d92ad91dc Mon Sep 17 00:00:00 2001 From: dundargoc Date: Sat, 26 Nov 2022 18:57:46 +0100 Subject: refactor: replace char_u with char Work on https://github.com/neovim/neovim/issues/459 --- src/nvim/context.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/context.c') diff --git a/src/nvim/context.c b/src/nvim/context.c index 47e60373bf..b064a92b74 100644 --- a/src/nvim/context.c +++ b/src/nvim/context.c @@ -264,7 +264,7 @@ static inline void ctx_save_funcs(Context *ctx, bool scriptonly) HASHTAB_ITER(func_tbl_get(), hi, { const char *const name = hi->hi_key; - bool islambda = (STRNCMP(name, "", 8) == 0); + bool islambda = (strncmp(name, "", 8) == 0); bool isscript = ((uint8_t)name[0] == K_SPECIAL); if (!islambda && (!scriptonly || isscript)) { -- cgit From 3269902a13df3bccf8705db73488c0a47f495514 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Sun, 15 Jan 2023 14:16:33 +0100 Subject: refactor: fix IWYU mapping file and use IWYU (#21802) Also add the EXITFREE definition to main_lib rather than the nvim target, as the header generation needs the EXITFREE flag to work properly. --- src/nvim/context.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/context.c') diff --git a/src/nvim/context.c b/src/nvim/context.c index b064a92b74..9de6c16536 100644 --- a/src/nvim/context.c +++ b/src/nvim/context.c @@ -5,7 +5,9 @@ #include #include +#include #include +#include #include "nvim/api/private/converter.h" #include "nvim/api/private/helpers.h" @@ -23,8 +25,6 @@ #include "nvim/message.h" #include "nvim/option.h" #include "nvim/shada.h" -#include "nvim/types.h" -#include "nvim/vim.h" #ifdef INCLUDE_GENERATED_DECLARATIONS # include "context.c.generated.h" -- cgit