From f87c8245133dd8116a9bab2d2e89f9b26967c7a8 Mon Sep 17 00:00:00 2001 From: bfredl Date: Sat, 9 Jul 2022 14:48:09 +0200 Subject: fix(rpc): break nvim_error_event feedback loop between two nvim instances In case nvim A sends nvim_error_event to nvim B, it would respond with another nvim_error_event due to unknown request name. Fix this by adding dummy request handler for now. --- src/nvim/api/vim.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/nvim/api/vim.c') diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 56516b2ac7..5d941890db 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -2256,3 +2256,11 @@ Dictionary nvim_eval_statusline(String str, Dict(eval_statusline) *opts, Error * return result; } + +void nvim_error_event(uint64_t channel_id, Integer lvl, String data) + FUNC_API_REMOTE_ONLY +{ + // TODO(bfredl): consider printing message to user, as will be relevant + // if we fork nvim processes as async workers + ELOG("async error on channel %" PRId64 ": %s", channel_id, data.size ? data.data : ""); +} -- cgit From f357c9bca59a58c8586a348d0d1dcd81116079a3 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 18 Jul 2022 08:54:53 +0800 Subject: vim-patch:8.1.1076: file for Insert mode is much too big Problem: File for Insert mode is much too big. Solution: Split off the code for Insert completion. (Yegappan Lakshmanan, closes vim/vim#4044) https://github.com/vim/vim/commit/7591bb39d58ece38a5fef984a08ea9012616c1f9 Cherry-pick ins_compl_len() -> get_compl_len() from patch 8.2.4001. Revert a71c5e9eb98fbb2ca88510269935cdcda37369fc: ctrl_x_mode is no longer a global variable, so l_ctrl_x_mode is no longer needed. --- src/nvim/api/vim.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/api/vim.c') diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 5d941890db..51807c9ca8 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -37,6 +37,7 @@ #include "nvim/highlight.h" #include "nvim/highlight_defs.h" #include "nvim/highlight_group.h" +#include "nvim/insexpand.h" #include "nvim/lua/executor.h" #include "nvim/mapping.h" #include "nvim/mark.h" -- cgit From c65e73f2d67785f7ba617f2c4e5cfc5de946b6ab Mon Sep 17 00:00:00 2001 From: bfredl Date: Tue, 19 Jul 2022 13:00:51 +0200 Subject: refactor(object): get rid of redundant FIXED_TEMP_ARRAY use the MAXSIZE_TEMP_ARRAY + ADD_C pattern instead, as exemplified by the changes in this commit. --- src/nvim/api/vim.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/nvim/api/vim.c') diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 51807c9ca8..256482fb38 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -473,10 +473,10 @@ Object nvim_exec_lua(String code, Array args, Error *err) Object nvim_notify(String msg, Integer log_level, Dictionary opts, Error *err) FUNC_API_SINCE(7) { - FIXED_TEMP_ARRAY(args, 3); - args.items[0] = STRING_OBJ(msg); - args.items[1] = INTEGER_OBJ(log_level); - args.items[2] = DICTIONARY_OBJ(opts); + MAXSIZE_TEMP_ARRAY(args, 3); + ADD_C(args, STRING_OBJ(msg)); + 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); } @@ -1010,10 +1010,10 @@ static void term_write(char *buf, size_t size, void *data) if (cb == LUA_NOREF) { return; } - FIXED_TEMP_ARRAY(args, 3); - args.items[0] = INTEGER_OBJ((Integer)chan->id); - args.items[1] = BUFFER_OBJ(terminal_buf(chan->term)); - args.items[2] = STRING_OBJ(((String){ .data = buf, .size = size })); + MAXSIZE_TEMP_ARRAY(args, 3); + ADD_C(args, INTEGER_OBJ((Integer)chan->id)); + ADD_C(args, BUFFER_OBJ(terminal_buf(chan->term))); + ADD_C(args, STRING_OBJ(((String){ .data = buf, .size = size }))); textlock++; nlua_call_ref(cb, "input", args, false, NULL); textlock--; -- cgit From db6e93c48df551e2906c9e0f4472f9e54cea3dd9 Mon Sep 17 00:00:00 2001 From: ii14 <59243201+ii14@users.noreply.github.com> Date: Mon, 1 Aug 2022 15:35:08 +0200 Subject: feat(api): add replace_keycodes to nvim_set_keymap (#19598) --- src/nvim/api/vim.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/nvim/api/vim.c') diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 256482fb38..dc57841b96 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -1447,7 +1447,8 @@ ArrayOf(Dictionary) nvim_get_keymap(uint64_t channel_id, String mode) /// Unknown key is an error. "desc" can be used to give a /// description to the mapping. When called from Lua, also accepts a /// "callback" key that takes a Lua function to call when the -/// mapping is executed. +/// mapping is executed. "replace_keycodes" can be used with "expr" +/// to replace keycodes, see |nvim_replace_termcodes()|. /// @param[out] err Error details, if any. void nvim_set_keymap(uint64_t channel_id, String mode, String lhs, String rhs, Dict(keymap) *opts, Error *err) -- cgit From 0a049c322fda5f2bb124429086c2713ff99c7142 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 2 Aug 2022 11:13:22 +0800 Subject: test: improve mapping tests and docs (#19619) --- src/nvim/api/vim.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'src/nvim/api/vim.c') diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index dc57841b96..e2f58dba62 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -1411,7 +1411,7 @@ Dictionary nvim_get_mode(void) /// Gets a list of global (non-buffer-local) |mapping| definitions. /// /// @param mode Mode short-name ("n", "i", "v", ...) -/// @returns Array of maparg()-like dictionaries describing mappings. +/// @returns Array of |maparg()|-like dictionaries describing mappings. /// The "buffer" key is always zero. ArrayOf(Dictionary) nvim_get_keymap(uint64_t channel_id, String mode) FUNC_API_SINCE(3) @@ -1423,8 +1423,8 @@ ArrayOf(Dictionary) nvim_get_keymap(uint64_t channel_id, String mode) /// /// To set a buffer-local mapping, use |nvim_buf_set_keymap()|. /// -/// Unlike |:map|, leading/trailing whitespace is accepted as part of the {lhs} -/// or {rhs}. Empty {rhs} is ||. |keycodes| are replaced as usual. +/// Unlike |:map|, leading/trailing whitespace is accepted as part of the {lhs} or {rhs}. +/// Empty {rhs} is ||. |keycodes| are replaced as usual. /// /// Example: ///
@@ -1441,14 +1441,15 @@ ArrayOf(Dictionary) nvim_get_keymap(uint64_t channel_id, String mode)
 ///               or "!" for |:map!|, or empty string for |:map|.
 /// @param  lhs   Left-hand-side |{lhs}| of the mapping.
 /// @param  rhs   Right-hand-side |{rhs}| of the mapping.
-/// @param  opts  Optional parameters map: keys are |:map-arguments|, values
-///               are booleans (default false). Accepts all |:map-arguments| as
-///               keys excluding || but including |noremap| and "desc".
-///               Unknown key is an error. "desc" can be used to give a
-///               description to the mapping. When called from Lua, also accepts a
-///               "callback" key that takes a Lua function to call when the
-///               mapping is executed. "replace_keycodes" can be used with "expr"
-///               to replace keycodes, see |nvim_replace_termcodes()|.
+/// @param  opts  Optional parameters map: keys are |:map-arguments|, values are booleans (default
+///               false). Accepts all |:map-arguments| as keys excluding || but including
+///               |noremap| and "desc". Unknown key is an error.
+///               "desc" can be used to give a description to the mapping.
+///               When called from Lua, also accepts a "callback" key that takes a Lua function to
+///               call when the mapping is executed.
+///               When "expr" is true, "replace_keycodes" (boolean) can be used to replace keycodes
+///               in the resulting string (see |nvim_replace_termcodes()|), and a Lua callback
+///               returning `nil` is equivalent to returning an empty string.
 /// @param[out]   err   Error details, if any.
 void nvim_set_keymap(uint64_t channel_id, String mode, String lhs, String rhs, Dict(keymap) *opts,
                      Error *err)
-- 
cgit