How it works
- You write a Kotlin class implementing
KlyxPlugin, annotated with@PluginManifest - The Klyx Kotlin compiler plugin validates the annotation and generates a
PluginDescriptorandplugin.jsonat compile time - The Klyx Gradle plugin packages everything into a
.klyxbundle (a gzipped tarball) - Klyx loads the bundle, reads the generated
plugin.json, and instantiates your plugin class - Your plugin registers screens, toolbar actions, file openers, and more during its lifecycle methods
- Klyx manages your plugin lifecycle automatically (load, start, stop, unload)
Bundle format
A.klyx file is a gzipped tarball containing:
plugin.json is generated for you by the @PluginManifest annotation and the compiler plugin, so you never hand-author or maintain this file.
Plugin lifecycle
Klyx calls four lifecycle methods on yourKlyxPlugin implementation:
See the lifecycle guide for details on each phase.
Service injection
Klyx provides services through property delegates. Useby plugin() for app-wide PluginService instances and by runtime() for per-plugin PluginRuntimeService instances.
currentPluginContext() and currentLifecycleOwner() functions to access runtime services without a delegate.
Registration with context receivers
Registration methods onScreenRegistry, ToolbarRegistry, FileOpenerRegistry, LanguageServerRegistry, and LanguageRegistry use Kotlin context receivers. The KlyxPlugin instance is provided as a context parameter, so you do not pass it explicitly:
What plugins can do
- Screens: Register custom Compose screens navigable from within Klyx
- Toolbar: Add toolbar actions with icons in custom categories
- File Openers: Handle custom file types (e.g.
.mp3,.svg,.pdf) - Terminal: Create and manage terminal sessions
- Processes: Run shell commands and programs with streaming output
- Events: Subscribe to app events (file opens, terminal events) and publish custom events
- Settings: Read and update app settings
- Language Servers: Register LSP providers for custom languages
- Language Grammars: Register tree-sitter syntax highlighting grammars for custom languages
- Theme: Use Klyx’s color system, typography, and fonts
- Diagnostics: Read device and editor capabilities