NuiTable can render table-like structured content on the buffer.
Examples
local NuiTable = require("nui.table")
local tbl = NuiTable({
bufnr = bufnr,
columns = {
{
align = "center",
header = "Name",
columns = {
{ accessor_key = "firstName", header = "First" },
{
id = "lastName",
accessor_fn = function(row)
return row.lastName
end,
header = "Last",
},
},
},
{
align = "right",
accessor_key = "age",
cell = function(cell)
return Text(tostring(cell.get_value()), "DiagnosticInfo")
end,
header = "Age",
},
},
data = {
{ firstName = "John", lastName = "Doe", age = 42 },
{ firstName = "Jane", lastName = "Doe", age = 27 },
},
})
tbl:render()
Type: number
Id of the buffer where the table will be rendered.
Type: number
or string
Namespace id (number
) or name (string
).
Type: NuiTable.ColumnDef[]
List of NuiTable.ColumnDef
objects.
Type: any[]
List of data items.
Signature: tbl:get_cell(position?: {integer, integer}) -> NuiTable.Cell | nil
Parameters
Name | Type | Description |
---|---|---|
position |
{ integer, integer } |
(row, col) tuple relative to cursor |
Returns the NuiTable.Cell
if found.
Signature: tbl:refresh_cell(cell: NuiTable.Cell) -> nil
Refreshes the cell
on buffer.
Parameters
Name | Type | Description |
---|---|---|
cell |
NuiTable.Cell |
cell |
Signature: tbl:render(linenr_start?: integer) -> nil
Renders the table on buffer.
Name | Type | Description |
---|---|---|
linenr_start |
integer / nil |
start line number (1-indexed) |
You can find additional documentation/examples/guides/tips-n-tricks in nui.table wiki page.