aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/api')
-rw-r--r--src/nvim/api/keysets_defs.h1
-rw-r--r--src/nvim/api/private/helpers.c4
-rw-r--r--src/nvim/api/vim.c6
3 files changed, 7 insertions, 4 deletions
diff --git a/src/nvim/api/keysets_defs.h b/src/nvim/api/keysets_defs.h
index 48f5f7246c..17287e083b 100644
--- a/src/nvim/api/keysets_defs.h
+++ b/src/nvim/api/keysets_defs.h
@@ -325,6 +325,7 @@ typedef struct {
} Dict(cmd_opts);
typedef struct {
+ Boolean err;
Boolean verbose;
} Dict(echo_opts);
diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c
index 78aa7c00f7..c98635f8fd 100644
--- a/src/nvim/api/private/helpers.c
+++ b/src/nvim/api/private/helpers.c
@@ -776,7 +776,7 @@ char *api_typename(ObjectType t)
UNREACHABLE;
}
-HlMessage parse_hl_msg(Array chunks, Error *err)
+HlMessage parse_hl_msg(Array chunks, bool is_err, Error *err)
{
HlMessage hl_msg = KV_INITIAL_VALUE;
for (size_t i = 0; i < chunks.size; i++) {
@@ -791,7 +791,7 @@ HlMessage parse_hl_msg(Array chunks, Error *err)
String str = copy_string(chunk.items[0].data.string, NULL);
- int hl_id = 0;
+ int hl_id = is_err ? HLF_E : 0;
if (chunk.size == 2) {
hl_id = object_to_hl_id(chunk.items[1], "text highlight", err);
}
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c
index e3e69f4ff6..f0848b7e04 100644
--- a/src/nvim/api/vim.c
+++ b/src/nvim/api/vim.c
@@ -775,13 +775,15 @@ void nvim_set_vvar(String name, Object value, Error *err)
/// `hl_group` element can be omitted for no highlight.
/// @param history if true, add to |message-history|.
/// @param opts Optional parameters.
+/// - err: Treat the message like |:echoerr|. Omitted `hlgroup`
+/// uses |hl-ErrorMsg| instead.
/// - verbose: Message is printed as a result of 'verbose' option.
/// If Nvim was invoked with -V3log_file, the message will be
/// redirected to the log_file and suppressed from direct output.
void nvim_echo(Array chunks, Boolean history, Dict(echo_opts) *opts, Error *err)
FUNC_API_SINCE(7)
{
- HlMessage hl_msg = parse_hl_msg(chunks, err);
+ HlMessage hl_msg = parse_hl_msg(chunks, opts->err, err);
if (ERROR_SET(err)) {
goto error;
}
@@ -790,7 +792,7 @@ void nvim_echo(Array chunks, Boolean history, Dict(echo_opts) *opts, Error *err)
verbose_enter();
}
- msg_multihl(hl_msg, history ? "echomsg" : "echo", history);
+ msg_multihl(hl_msg, opts->err ? "echoerr" : history ? "echomsg" : "echo", history, opts->err);
if (opts->verbose) {
verbose_leave();