Lua Type Aliases
Yazi defines several type aliases used across the plugin API to clarify what kinds of values are expected in different contexts.
Origin
Marks a value as originating from a specific context. Used for ownership tracking between sync and async.
-- Origin values carry context ownership information
local origin_file = some_origin_value -- owned by e.g. sync context
Sendable
A value that is safe to send between contexts (sync ↔ async). All primitive Lua types are Sendable. Composite types must be explicitly marked.
| Type | Sendable? |
|---|---|
nil | Yes |
boolean | Yes |
number | Yes |
string | Yes |
table | Yes (if all keys/values are Sendable) |
function | No |
Values that cross the sync/async boundary must be Sendable.
Renderable
Any value that can be rendered by the UI system. This includes:
Span— A styled text spanLine— A row of spansText— A multi-line blockList— A scrollable listParagraph— A wrapped text blockGauge— A progress barTable— A table widgetBar— A directional barBorder— A bordered frameClear— An area clearSparkline— A sparkline chart
AsPos
A value that can be converted to a Pos. Accepts:
-- Table with x, y keys
ui.Pos { x = 1, y = 2 }
-- Table with col, row keys
ui.Pos { col = 1, row = 2 }
AsSpan
A value that can be converted to a Span. Accepts:
-- Plain string
ui.Span("hello")
-- Styled string
ui.Span({ text = "hello", fg = "red" })
AsLine
A value that can be converted to a Line. Accepts:
-- Single span
ui.Line { "text" }
-- Multiple spans
ui.Line { "hello", ui.Span("world"):bold() }
-- Array of strings
ui.Line { "part1", "part2" }
Span
A styled text segment — the fundamental building block of rendered text.
| Method | Description |
|---|---|
:fg(color) | Set foreground color |
:bg(color) | Set background color |
:bold() | Bold text |
:italic() | Italic text |
:underline() | Underlined text |
:crossed_out() | Strikethrough text |
ui.Span("Warning: "):fg("yellow"):bold()
Line
A row composed of multiple Span values.
ui.Line {
ui.Span("Name: "):fg("blue"),
ui.Span("report.pdf"):bold(),
}
Colors can be specified as strings ("red", "#ff0000") or as Rgb values.
All type aliases are conceptual — they document the expected shape of values rather than providing explicit type annotations.