Skip to main content

Plugin API Reference

ya.* Utility API

FunctionSignatureDescription
ya.file_cacheya.file_cache(File) -> string?Get cache path for a file (creates if missing)
ya.emitya.emit(string, table?)Emit a Yazi event with optional data
ya.image_showya.image_show(string, Rect)Display an image at the given area
ya.image_precacheya.image_precache(string)Pre-cache an image in the background
ya.image_clearya.image_clear()Clear displayed images
ya.managerya.manager() -> ManagerGet the current manager state
ya.syncya.sync(function)Run a function synchronously on the main thread
ya.hideya.hide()Hide the preview / restore normal view
ya.inputya.input(string, table?) -> string?Show an input prompt
ya.openya.open(Url)Open a URL with the system handler
ya.psya.ps() -> Process[]List running plugin processes
ya.ddsya.dds() -> DDSGet the DDS (pub-sub) interface
ya.mountya.mount() -> Mount[]List mounted filesystems
ya.preview_codeya.preview_code(string, string)Preview a code file with syntax highlighting
ya.whichya.which(string, table)Show a which key binding overlay
ya.notifyya.notify(string, table)Show a desktop notification

ya.emit Event Examples

-- Emit a "cd" event to navigate
ya.emit("cd", { url = "/home/user/projects" })

-- Emit a "quit" event
ya.emit("quit")

-- Emit a custom event for plugins
ya.emit("custom-event", { data = "hello" })

Context API

The cx variable (available in plugin callbacks) provides the current state:

FieldTypeDescription
cx.activePaneThe currently focused pane
cx.tabsTab[]All open tabs
cx.tasksTask[]Current running tasks
cx.yankedFile[]Currently yanked files
cx.mode"normal" / "visual"Current input mode
cx.panesPane[]All panes (parent, current, preview)
cx.timenumberCurrent timestamp (monotonic)

Pane Fields

FieldTypeDescription
pane.currentFileCurrently highlighted file
pane.filesFile[]Files in the current directory
pane.cwdUrlCurrent working directory
pane.selectedFile[]Selected files

File Fields

FieldTypeDescription
file.urlUrlFull URL of the file
file.namestringFile name
file.extstringFile extension (lowercase)
file.sizenumberFile size in bytes
file.chaChaFile metadata (permissions, type)
file.is_dirbooleanWhether the file is a directory

Preload / Peek API

Previewer plugins implement one or both of these methods:

MethodSignatureWhen Called
:preload(job)preload(job)In background to pre-generate cache
:peek(job)peek(job)To display the preview

Job Fields

FieldTypeDescription
job.fileFileFile to preview
job.areaRectAvailable display area (x, y, w, h)
job.skipnumberNumber of lines to skip (for text preview)

Plugin Lifecycle Hooks

HookDescription
:setup()Called once when plugin is loaded
:preload(job)Background cache generation
:peek(job)Foreground preview display
:seek(job)Handle scroll/seeking within preview