Closed ten3roberts closed 1 year ago
Is there a way to batch together many lines and call the api and update the buffer only once with all the line.
which will do a single
nvim_buf_set_lines
and apply the highlights.
Are you concerned about the performance? If you want to render multiple NuiLine
with a single nvim_buf_set_lines
call, you'd still need to apply highlights using multiple calls and also keep additional states to keep track of the boundaries to apply highlights. I don't think it's worth it.
If you want the convenience of rending multiple lines together, you can write a small wrapper:
local function render_lines(lines, bufnr, ns_id, linenr_start)
for i, line in ipairs(lines) do
line:render(bufnr, ns_id, linenr_start + i - 1)
end
end
and use it as:
render_lines({
NuiLine({ NuiText("Foo") }),
NuiLine({ NuiText("On Line 2"), NuiText("Bar") }),
}, bufnr, ns_id, 1)
Currently, you can call
NuiLine:render
to update a single line.Is there a way to batch together many lines and call the api and update the buffer only once with all the line.
Alternatively, a
NuiBlock
or similar construct contains lines similar to howNuiLine
"contains"NuiText
objects.E.g
which will do a single
nvim_buf_set_lines
and apply the highlights.