aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nvim/README.md28
-rw-r--r--src/nvim/api/command.c2
-rw-r--r--src/nvim/api/deprecated.c17
-rw-r--r--src/nvim/api/keysets.lua3
-rw-r--r--src/nvim/api/vimscript.c36
-rw-r--r--src/nvim/context.c7
-rw-r--r--src/nvim/eval/funcs.c2
-rw-r--r--src/nvim/indent_c.c4
-rw-r--r--src/nvim/insexpand.c4
-rw-r--r--src/nvim/main.c7
-rw-r--r--src/nvim/path.c1
-rw-r--r--src/nvim/regexp_nfa.c1
-rw-r--r--src/nvim/shada.c1
13 files changed, 91 insertions, 22 deletions
diff --git a/src/nvim/README.md b/src/nvim/README.md
index 69d5939c70..cbd5daba4e 100644
--- a/src/nvim/README.md
+++ b/src/nvim/README.md
@@ -198,6 +198,34 @@ possible to see exactly what terminfo values Nvim is using on any system.
nvim -V3log
+### TUI Debugging with gdb/lldb
+
+Launching the nvim TUI involves two processes, one for main editor state and one
+for rendering the TUI. Both of these processes use the nvim binary, so somewhat
+confusingly setting a breakpoint in either will generally succeed but may not be
+hit depending on which process the breakpoints were set in.
+
+To debug the main process, you can debug the nvim binary with the `--headless`
+flag which does not launch the TUI and will allow you to set breakpoints in code
+not related to TUI rendering like so:
+
+```
+lldb -- ./build/bin/nvim --headless --listen ~/.cache/nvim/debug-server.pipe
+```
+
+You can then attach to the headless process to interact with the editor like so:
+
+```
+./build/bin/nvim --remote-ui --server ~/.cache/nvim/debug-server.pipe
+```
+
+Conversely for debugging TUI rendering, you can start a headless process and
+debug the remote-ui process multiple times without losing editor state.
+
+For details on using nvim-dap and automatically debugging the child (main)
+process, see
+[here](https://zignar.net/2023/02/17/debugging-neovim-with-neovim-and-nvim-dap/)
+
### TUI trace
The ancient `script` command is still the "state of the art" for tracing
diff --git a/src/nvim/api/command.c b/src/nvim/api/command.c
index 1455f28050..26ee9205b2 100644
--- a/src/nvim/api/command.c
+++ b/src/nvim/api/command.c
@@ -307,7 +307,7 @@ end:
///
/// On execution error: fails with VimL error, updates v:errmsg.
///
-/// @see |nvim_exec()|
+/// @see |nvim_exec2()|
/// @see |nvim_command()|
///
/// @param cmd Command to execute. Must be a Dictionary that can contain the same values as
diff --git a/src/nvim/api/deprecated.c b/src/nvim/api/deprecated.c
index b1e2e6811e..6a12cfe2da 100644
--- a/src/nvim/api/deprecated.c
+++ b/src/nvim/api/deprecated.c
@@ -27,13 +27,26 @@
# include "api/deprecated.c.generated.h"
#endif
+/// @deprecated Use nvim_exec2() instead.
+/// @see nvim_exec2
+String nvim_exec(uint64_t channel_id, String src, Boolean output, Error *err)
+ FUNC_API_SINCE(7)
+ FUNC_API_DEPRECATED_SINCE(11)
+{
+ Dict(exec_opts) opts = { 0 };
+ opts.output = BOOLEAN_OBJ(output);
+ return exec_impl(channel_id, src, &opts, err);
+}
+
/// @deprecated
-/// @see nvim_exec
+/// @see nvim_exec2
String nvim_command_output(uint64_t channel_id, String command, Error *err)
FUNC_API_SINCE(1)
FUNC_API_DEPRECATED_SINCE(7)
{
- return nvim_exec(channel_id, command, true, err);
+ Dict(exec_opts) opts = { 0 };
+ opts.output = BOOLEAN_OBJ(true);
+ return exec_impl(channel_id, command, &opts, err);
}
/// @deprecated Use nvim_exec_lua() instead.
diff --git a/src/nvim/api/keysets.lua b/src/nvim/api/keysets.lua
index b2b327d73e..ce29001787 100644
--- a/src/nvim/api/keysets.lua
+++ b/src/nvim/api/keysets.lua
@@ -232,4 +232,7 @@ return {
{ 'echo_opts', {
"verbose";
}};
+ { 'exec_opts', {
+ "output";
+ }};
}
diff --git a/src/nvim/api/vimscript.c b/src/nvim/api/vimscript.c
index 32dcbdec3f..2438a5cf1d 100644
--- a/src/nvim/api/vimscript.c
+++ b/src/nvim/api/vimscript.c
@@ -45,13 +45,33 @@
/// @see |nvim_cmd()|
///
/// @param src Vimscript code
-/// @param output Capture and return all (non-error, non-shell |:!|) output
+/// @param opts Optional parameters.
+/// - output: (boolean, default false) Whether to capture and return
+/// all (non-error, non-shell |:!|) output.
/// @param[out] err Error details (Vim error), if any
-/// @return Output (non-error, non-shell |:!|) if `output` is true,
-/// else empty string.
-String nvim_exec(uint64_t channel_id, String src, Boolean output, Error *err)
- FUNC_API_SINCE(7)
+/// @return Dictionary containing information about execution, with these keys:
+/// - output: (string|nil) Output if `opts.output` is true.
+Dictionary nvim_exec2(uint64_t channel_id, String src, Dict(exec_opts) *opts, Error *err)
+ FUNC_API_SINCE(11)
{
+ Dictionary result = ARRAY_DICT_INIT;
+
+ String output = exec_impl(channel_id, src, opts, err);
+ if (ERROR_SET(err)) {
+ return result;
+ }
+
+ if (HAS_KEY(opts->output) && api_object_to_bool(opts->output, "opts.output", false, err)) {
+ PUT(result, "output", STRING_OBJ(output));
+ }
+
+ return result;
+}
+
+String exec_impl(uint64_t channel_id, String src, Dict(exec_opts) *opts, Error *err)
+{
+ Boolean output = api_object_to_bool(opts->output, "opts.output", false, err);
+
const int save_msg_silent = msg_silent;
garray_T *const save_capture_ga = capture_ga;
const int save_msg_col = msg_col;
@@ -69,7 +89,7 @@ String nvim_exec(uint64_t channel_id, String src, Boolean output, Error *err)
const sctx_T save_current_sctx = api_set_sctx(channel_id);
- do_source_str(src.data, "nvim_exec()");
+ do_source_str(src.data, "nvim_exec2()");
if (output) {
capture_ga = save_capture_ga;
msg_silent = save_msg_silent;
@@ -108,8 +128,8 @@ theend:
///
/// On execution error: fails with VimL error, updates v:errmsg.
///
-/// Prefer using |nvim_cmd()| or |nvim_exec()| over this. To evaluate multiple lines of Vim script
-/// or an Ex command directly, use |nvim_exec()|. To construct an Ex command using a structured
+/// Prefer using |nvim_cmd()| or |nvim_exec2()| over this. To evaluate multiple lines of Vim script
+/// or an Ex command directly, use |nvim_exec2()|. To construct an Ex command using a structured
/// format and then execute it, use |nvim_cmd()|. To modify an Ex command before evaluating it, use
/// |nvim_parse_cmd()| in conjunction with |nvim_cmd()|.
///
diff --git a/src/nvim/context.c b/src/nvim/context.c
index 9de6c16536..b13a331eff 100644
--- a/src/nvim/context.c
+++ b/src/nvim/context.c
@@ -10,6 +10,7 @@
#include <string.h>
#include "nvim/api/private/converter.h"
+#include "nvim/api/private/defs.h"
#include "nvim/api/private/helpers.h"
#include "nvim/api/vimscript.h"
#include "nvim/context.h"
@@ -271,8 +272,10 @@ static inline void ctx_save_funcs(Context *ctx, bool scriptonly)
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),
- true, &err);
+ Dict(exec_opts) opts = { 0 };
+ opts.output = BOOLEAN_OBJ(true);
+ String func_body = exec_impl(VIML_INTERNAL_CALL, cstr_as_string(cmd),
+ &opts, &err);
xfree(cmd);
if (!ERROR_SET(&err)) {
ADD(ctx->funcs, STRING_OBJ(func_body));
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c
index 3a7da21606..df8004dc73 100644
--- a/src/nvim/eval/funcs.c
+++ b/src/nvim/eval/funcs.c
@@ -7581,7 +7581,7 @@ static void f_settagstack(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
// third argument: action - 'a' for append and 'r' for replace.
// default is to replace the stack.
if (argvars[2].v_type == VAR_UNKNOWN) {
- action = 'r';
+ // action = 'r';
} else if (argvars[2].v_type == VAR_STRING) {
const char *actstr;
actstr = tv_get_string_chk(&argvars[2]);
diff --git a/src/nvim/indent_c.c b/src/nvim/indent_c.c
index 3e7f640326..f7bf9c46a4 100644
--- a/src/nvim/indent_c.c
+++ b/src/nvim/indent_c.c
@@ -525,7 +525,9 @@ static bool cin_is_cpp_namespace(const char *s)
s = cin_skipcomment(s);
- if (strncmp(s, "inline", 6) == 0 && (s[6] == NUL || !vim_iswordc((uint8_t)s[6]))) {
+ // skip over "inline" and "export" in any order
+ while ((strncmp(s, "inline", 6) == 0 || strncmp(s, "export", 6) == 0)
+ && (s[6] == NUL || !vim_iswordc((uint8_t)s[6]))) {
s = cin_skipcomment(skipwhite(s + 6));
}
diff --git a/src/nvim/insexpand.c b/src/nvim/insexpand.c
index c61c74c607..7100146245 100644
--- a/src/nvim/insexpand.c
+++ b/src/nvim/insexpand.c
@@ -2890,7 +2890,7 @@ static int process_next_cpt_value(ins_compl_next_state_T *st, int *compl_type_ar
status = INS_COMPL_CPT_END;
} else {
if (ctrl_x_mode_line_or_eval()) {
- compl_type = -1;
+ // compl_type = -1;
} else if (*st->e_cpt == 'k' || *st->e_cpt == 's') {
if (*st->e_cpt == 'k') {
compl_type = CTRL_X_DICTIONARY;
@@ -2912,8 +2912,6 @@ static int process_next_cpt_value(ins_compl_next_state_T *st, int *compl_type_ar
vim_snprintf(IObuff, IOSIZE, "%s", _("Scanning tags."));
(void)msg_trunc_attr(IObuff, true, HL_ATTR(HLF_R));
}
- } else {
- compl_type = -1;
}
// in any case e_cpt is advanced to the next entry
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 <assert.h>
#include <limits.h>
#include <msgpack/pack.h>
diff --git a/src/nvim/path.c b/src/nvim/path.c
index 9bbf56276e..973e5eaec4 100644
--- a/src/nvim/path.c
+++ b/src/nvim/path.c
@@ -2375,7 +2375,6 @@ static int path_to_absolute(const char *fname, char *buf, size_t len, int force)
end_of_path = p + 1;
} else {
relative_directory[0] = NUL;
- end_of_path = (char *)fname;
}
if (FAIL == path_full_dir_name(relative_directory, buf, len)) {
diff --git a/src/nvim/regexp_nfa.c b/src/nvim/regexp_nfa.c
index ea59e7d464..950814880b 100644
--- a/src/nvim/regexp_nfa.c
+++ b/src/nvim/regexp_nfa.c
@@ -2238,7 +2238,6 @@ collection:
}
// Failed to recognize a character class. Use the simple
// version that turns [abc] into 'a' OR 'b' OR 'c'
- startc = -1;
negated = false;
if (*regparse == '^') { // negated range
negated = true;
diff --git a/src/nvim/shada.c b/src/nvim/shada.c
index 98f10c0082..3f816d0172 100644
--- a/src/nvim/shada.c
+++ b/src/nvim/shada.c
@@ -3602,7 +3602,6 @@ shada_read_next_item_start:
ret = spm_ret;
goto shada_read_next_item_error;
}
- ret = kSDReadStatusMalformed;
entry->data = sd_default_values[type_u64].data;
switch ((ShadaEntryType)type_u64) {
case kSDItemHeader: