Documentation Index
Fetch the complete documentation index at: https://mintlify.com/sxyazi/yazi/llms.txt
Use this file to discover all available pages before exploring further.
Introduction
Yazi provides a powerful Lua plugin API that allows you to extend and customize its functionality. Plugins can be used for:- Custom file previewers
- File operations and automation
- UI components and themes
- Integration with external tools
- Custom actions and keybindings
Lua Version
Yazi uses Lua 5.5 as of version 0.4.0 (upgraded from Lua 5.4). This upgrade brings performance improvements through external strings, reducing memory allocations.Lua 5.5 introduces external strings for better memory efficiency. See #3633 for details.
API Namespaces
The plugin API is organized into several global namespaces:Core APIs
ya- Core Yazi API for async operations, sync blocks, logging, and utilitiesfs- Filesystem operations (copy, rename, read_dir, etc.)ui- UI rendering components and helpersps- Publish/Subscribe messaging systemcx- Context API for accessing application state
Configuration APIs
rt- Runtime configuration (args, mgr, preview, tasks, etc.)th- Theme colors and styling
Async Support
Yazi’s plugin system supports asynchronous operations through Lua coroutines:Module-level Async
Plugins can use the@sync annotation to declare async entry points:
Runtime Async
For dynamic async operations, useya.async():
Sync Blocks
Useya.sync() to execute code in the main thread with access to the plugin context:
Plugin Types
Yazi supports several types of plugins:Previewers
Generate file previews for the preview pane:Preloaders
Load file metadata in the background:Actions
Custom user actions triggered by keybindings:Init Plugins
Run on startup frominit.lua:
Error Handling
Most async APIs return(result, error) tuples:
Data Types
Common userdata types:Url- File/directory URL (local or remote)Path- Local filesystem pathFile- File metadata and attributesCha- File characteristics (size, permissions, etc.)Rect- Screen rectangle (x, y, w, h)Id- Unique identifier
Best Practices
- Use async APIs - Most filesystem operations are async for better performance
- Handle errors - Always check error returns from async functions
- Cache data - Use
ya.file_cache()for expensive operations - Limit resources - Use options like
limitinfs.read_dir()to avoid loading too much data - Clean up - Drop file descriptors and handles when done using
ya.drop()
Next Steps
- Global Functions - Global utility functions
- Filesystem API - File operations
- UI API - Rendering components
- Context API - Application state
- Yazi API - Core utilities
- PubSub API - Messaging system