mirror of
https://github.com/neovim/neovim
synced 2025-07-16 01:01:49 +00:00
fix: type of nvim_echo
This commit is contained in:
committed by
Lewis Russell
parent
f731766474
commit
38aac21083
@ -651,7 +651,7 @@ nvim_echo({chunks}, {history}, {opts}) *nvim_echo()*
|
|||||||
Since: 0.5.0
|
Since: 0.5.0
|
||||||
|
|
||||||
Parameters: ~
|
Parameters: ~
|
||||||
• {chunks} (`[string, integer|string][]`) List of `[text, hl_group]`
|
• {chunks} (`[string, integer|string?][]`) List of `[text, hl_group]`
|
||||||
pairs, where each is a `text` string highlighted by the
|
pairs, where each is a `text` string highlighted by the
|
||||||
(optional) name or ID `hl_group`.
|
(optional) name or ID `hl_group`.
|
||||||
• {history} (`boolean`) if true, add to |message-history|.
|
• {history} (`boolean`) if true, add to |message-history|.
|
||||||
|
2
runtime/lua/vim/_meta/api.lua
generated
2
runtime/lua/vim/_meta/api.lua
generated
@ -1096,7 +1096,7 @@ function vim.api.nvim_del_var(name) end
|
|||||||
--- vim.api.nvim_echo({ { 'chunk1-line1\nchunk1-line2\n' }, { 'chunk2-line1' } }, true, {})
|
--- vim.api.nvim_echo({ { 'chunk1-line1\nchunk1-line2\n' }, { 'chunk2-line1' } }, true, {})
|
||||||
--- ```
|
--- ```
|
||||||
---
|
---
|
||||||
--- @param chunks [string, integer|string][] List of `[text, hl_group]` pairs, where each is a `text` string highlighted by
|
--- @param chunks [string, integer|string?][] List of `[text, hl_group]` pairs, where each is a `text` string highlighted by
|
||||||
--- the (optional) name or ID `hl_group`.
|
--- the (optional) name or ID `hl_group`.
|
||||||
--- @param history boolean if true, add to `message-history`.
|
--- @param history boolean if true, add to `message-history`.
|
||||||
--- @param opts vim.api.keyset.echo_opts Optional parameters.
|
--- @param opts vim.api.keyset.echo_opts Optional parameters.
|
||||||
|
@ -770,14 +770,14 @@ char *api_typename(ObjectType t)
|
|||||||
UNREACHABLE;
|
UNREACHABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
HlMessage parse_hl_msg(Array chunks, bool is_err, Error *err)
|
HlMessage parse_hl_msg(ArrayOf(Tuple(String, *HLGroupID)) chunks, bool is_err, Error *err)
|
||||||
{
|
{
|
||||||
HlMessage hl_msg = KV_INITIAL_VALUE;
|
HlMessage hl_msg = KV_INITIAL_VALUE;
|
||||||
for (size_t i = 0; i < chunks.size; i++) {
|
for (size_t i = 0; i < chunks.size; i++) {
|
||||||
VALIDATE_T("chunk", kObjectTypeArray, chunks.items[i].type, {
|
VALIDATE_T("chunk", kObjectTypeArray, chunks.items[i].type, {
|
||||||
goto free_exit;
|
goto free_exit;
|
||||||
});
|
});
|
||||||
Array chunk = chunks.items[i].data.array;
|
Tuple(String, *HLGroupID) chunk = chunks.items[i].data.array;
|
||||||
VALIDATE((chunk.size > 0 && chunk.size <= 2 && chunk.items[0].type == kObjectTypeString),
|
VALIDATE((chunk.size > 0 && chunk.size <= 2 && chunk.items[0].type == kObjectTypeString),
|
||||||
"%s", "Invalid chunk: expected Array with 1 or 2 Strings", {
|
"%s", "Invalid chunk: expected Array with 1 or 2 Strings", {
|
||||||
goto free_exit;
|
goto free_exit;
|
||||||
@ -785,10 +785,10 @@ HlMessage parse_hl_msg(Array chunks, bool is_err, Error *err)
|
|||||||
|
|
||||||
String str = copy_string(chunk.items[0].data.string, NULL);
|
String str = copy_string(chunk.items[0].data.string, NULL);
|
||||||
|
|
||||||
int hl_id = is_err ? HLF_E : 0;
|
int hl_id =
|
||||||
if (chunk.size == 2) {
|
chunk.size == 2 ? object_to_hl_id(chunk.items[1], "text highlight", err)
|
||||||
hl_id = object_to_hl_id(chunk.items[1], "text highlight", err);
|
: is_err ? HLF_E
|
||||||
}
|
: 0;
|
||||||
kv_push(hl_msg, ((HlMessageChunk){ .text = str, .hl_id = hl_id }));
|
kv_push(hl_msg, ((HlMessageChunk){ .text = str, .hl_id = hl_id }));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -762,7 +762,7 @@ void nvim_set_vvar(String name, Object value, Error *err)
|
|||||||
/// - kind: Set the |ui-messages| kind with which this message will be emitted.
|
/// - kind: Set the |ui-messages| kind with which this message will be emitted.
|
||||||
/// - verbose: Message is controlled by the 'verbose' option. Nvim invoked with `-V3log`
|
/// - verbose: Message is controlled by the 'verbose' option. Nvim invoked with `-V3log`
|
||||||
/// will write the message to the "log" file instead of standard output.
|
/// will write the message to the "log" file instead of standard output.
|
||||||
void nvim_echo(ArrayOf(Tuple(String, HLGroupID)) chunks, Boolean history, Dict(echo_opts) *opts,
|
void nvim_echo(ArrayOf(Tuple(String, *HLGroupID)) chunks, Boolean history, Dict(echo_opts) *opts,
|
||||||
Error *err)
|
Error *err)
|
||||||
FUNC_API_SINCE(7)
|
FUNC_API_SINCE(7)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user