Skip to main content

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.

TypeSendable?
nilYes
booleanYes
numberYes
stringYes
tableYes (if all keys/values are Sendable)
functionNo

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 span
  • Line — A row of spans
  • Text — A multi-line block
  • List — A scrollable list
  • Paragraph — A wrapped text block
  • Gauge — A progress bar
  • Table — A table widget
  • Bar — A directional bar
  • Border — A bordered frame
  • Clear — An area clear
  • Sparkline — 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.

MethodDescription
: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.

info

All type aliases are conceptual — they document the expected shape of values rather than providing explicit type annotations.