NuiLine is an abstraction layer on top of the following native functions:
vim.api.nvim_buf_set_lines
(check:h nvim_buf_set_lines()
)vim.api.nvim_buf_set_text
(check:h nvim_buf_set_text()
)vim.api.nvim_buf_add_highlight
(check:h nvim_buf_add_highlight()
)
It helps you create line on the buffer containing multiple NuiText
s.
Signature: NuiLine(texts?)
Example
local NuiLine = require("nui.line")
local line = NuiLine()
line:append("Something Went Wrong!", "Error")
local bufnr, ns_id, linenr_start = 0, -1, 1
line:render(bufnr, ns_id, linenr_start)
Type: table[]
List of NuiText
objects to set as initial texts.
Example
local text_one = NuiText("One")
local text_two = NuiText("Two")
local line = NuiLine({ text_one, text_two })
Signature: line:append(content, highlight?)
Adds a chunk of content to the line.
Parameters
Name | Type | Description |
---|---|---|
content |
string / NuiText / NuiLine |
content |
highlight |
string or table |
highlight information |
If text
is string
, these parameters are passed to NuiText
and a NuiText
object is returned.
It content
is a NuiText
/NuiLine
object, it is returned unchanged.
Signature: line:content()
Returns the line content.
Signature: line:highlight(bufnr, ns_id, linenr)
Applies highlight for the line.
Parameters
Name | Type | Description |
---|---|---|
bufnr |
number |
buffer number |
ns_id |
number |
namespace id (use -1 for fallback namespace) |
linenr |
number |
line number (1-indexed) |
Signature: line:render(bufnr, ns_id, linenr_start, linenr_end?)
Sets the line on buffer and applies highlight.
Parameters
Name | Type | Description |
---|---|---|
bufnr |
number |
buffer number |
ns_id |
number |
namespace id (use -1 for fallback namespace) |
linenr_start |
number |
start line number (1-indexed) |
linenr_end |
number |
end line number (1-indexed) |
You can find additional documentation/examples/guides/tips-n-tricks in nui.line wiki page.