Plugin reference
On this page
What a plugin's author looks up while writing one: the capabilities and their risks, the slots, the events, the limits, the errors and the manifest. The guide tells how to write a plugin step by step; lokyr.d.luau, which sleip new puts beside the plugin, is the reference of each call of cx, its arguments and its answer, of a comment each.
The manifest
plugin.toml holds the plugin's name, owner/name, its version, its license, its description, the plugin API that it takes, api = "^0.1", its entry, its activation, the capabilities that it asks for, the commands of others that it runs, [uses] commands, and what it contributes: its slots, its config's schema and its catalogs. Every field is in plugin.toml's reference; sleip check checks the manifest as the registry does.
- Activation: a plugin starts as one of its triggers comes,
command:<name>of its own commands,event:<name>orslot:<name>, rather than as Lokyr starts; one of no trigger starts with the app. - Replaces:
[plugin] replaces = ["lokyr/tabs"]names the plugins that it stands in for in the same place, as a tab bar of its own in place of Lokyr's: Lokyr turns them off while it runs, once you grant it, and on again as it goes · Since 1.4. - Its namespace is its name after the owner, as
helloofacme/hello: its commands arehello.<action>, its eventshello.<name>, its config the section[plugins.hello], and no other plugin has it.
Capabilities
A capability lets a plugin reach what belongs to the person who runs Lokyr. The manifest declares the capabilities, sleip add shows them, and Lokyr asks for them at the plugin's first activation, each of its risk, its default button refusing; a refused capability makes the calls that need it fail with denied.
| Capability | Allows | Risk |
|---|---|---|
| (none) | Registering commands, and running those that the manifest declares; keymap, events, UI, themes, config, storage, logging, timers | — |
terminal-read | Reading screen and scrollback text, and the selection | High: the screen may show secrets |
pty-write | Sending input to the shell | Very high |
clipboard-read | Reading the clipboard | High |
clipboard-write | Writing to the clipboard | Medium |
notifications | Showing system notifications | Low |
open | Opening URLs and files with the system handler | Medium |
process-spawn | Starting processes; refused before 1.0.0, with a notice | Very high |
net:<host> | HTTP requests to the listed hosts, whatever their case; refused before 1.0.0, with a notice | High |
fs-read:<path>, fs-write:<path> | Access to the listed paths and to the paths under them, of whole components and no .. | High |
global-hotkey | System-wide shortcuts, bindings of global: keys, the double taps of modifiers from any app, and quick windows, which slide in over every app's | Medium |
env-read:<name> | Reading the listed variables of the app's environment and of the panes' programs', with * as AWS_* | High: they often hold secrets, as GITHUB_TOKEN |
input-read | Seeing the keys typed before they reach the program | Very high: a keylogger's power |
history-read | Reading the commands that the shell ran and their output, which shell integration marks, and hearing their starts and ends of their exit statuses | High: a password typed by mistake ends up there |
process-read | Seeing the panes' processes: their command lines and working directories, a folder's git branch, the programs that run and the agents' states, and the folders where the shells worked last; hearing as a command starts and ends, of no exit status · Since 1.4; a pane's title of its parts, its program's name, its own title and its folder · Since 1.7 | Medium: command lines can hold passwords |
workspace-write | Opening, closing and moving windows, tabs and panes, the keyboard's focus between them, a split's ratio, the zoom, pinned tabs, groups of tabs, sessions made and switched, and the app's quit; the typed input broadcast to a tab or a window, and popups that run a command, both with pty-write · Since 1.5; a new pane's environment variables, with pty-write · Since 1.6 | High: it can end every program, start shells, or move the keys typed to another pane |
pane-view | The panes' scroll and selection, the screen and the scrollback cleared, the font's size, the tabs' titles and colors, the tab bar's place, the inactive panes' fade and the focus that follows the mouse; the panes' look, as cards or plain, and the programs' icons of their headers · Since 1.7 | Medium: a cleared scrollback is lost text |
decorate | Drawing over a pane: decorations, the gutter's marks, a search's matches and a held cursor | Medium: a drawing over the text can show what the terminal does not hold |
pointer-read | The pointer event: the cell under the pointer over the panes, and the modifiers held | Low |
keep-awake | Keeping the system, or the system and the display, from idle sleep | High: a display kept awake keeps the screen from locking |
config | The config in force, every key of the app's and of the plugins' sections, with their schemas, and the themes folder's files, a theme copied or made, an .itermcolors one converted, or a theme's colors written; Lokyr's own plugins' alone | Very high: a key written can change the program that a pane runs |
packages | The plugins themselves, through Sleip: the installed ones, the registry's search, installs, updates and removals; every plugin's state and the decisions of its capabilities, and a plugin turned on or off in the config; Lokyr's own plugins' alone | Very high: a plugin that installs another runs code of its choice |
automation | The requests of scripts and shortcuts from outside Lokyr, the automation event, and their answers, answer_automation; Lokyr's own plugins' alone · Since 1.6 | Very high: a script's request can run any command and read a pane's text |
user-commands | Running any command as if run by hand, without declaring it, as the palette does; reading the whole registry of commands and the menu bar's items; a key pressed as you press it, which runs its shortcut's command, with pty-write · Since 1.6 | Very high: pane.send-text types into the shell |
appearance-write | Previewing a theme, a monospaced font family and a face's style, and naming the ones chosen in the config's [theme] and [font] family | Medium: the config changes, visibly and reversibly |
replaces:<plugin> | Turning the plugin of that name off while this one runs, as both show in the same place, of the manifest's [plugin] replaces rather than of [capabilities]; never lokyr/plugin-manager · Since 1.4 | High: what the other plugin did goes while this one runs |
A request takes every capability that it needs, as a subscription to pointer and to command-started takes pointer-read and history-read or process-read. The reads of the workspace, the plugin's own views, panels and questions, its declarations, its config and its state take none; neither does a file saved through the save panel, where the place is chosen in the panel and Lokyr writes it.
Slots
A slot is a place of the window that plugins' views fill; a plugin names the slots of its views in its manifest's contributes.slots.
| Slot | Plugins | What it shows |
|---|---|---|
tab-bar | One, chosen in the config | The tab bar, in the titlebar, below it, at the window's bottom or down a column at its side |
title-buttons | Many, three at most, more behind a menu | A button of an icon right after the window's buttons, as a toggle of a state that the plugin keeps |
status-bar | Many, on three sides | Status information across the window's bottom, of its tallest view's height, over a band of status-bar.bg across the window, each view at its width on its side, start, center or end, of the manifest's [contributes.status-bar] side or cx.set_status_bar_side · Since 1.4 |
window-strip | Many | A thin strip across the panes' top, over them, as the programs' progress |
pane-header | One | A header across each pane's top, above its grid |
Floating panels are no slot: a plugin opens and closes them, anchored to a cell, the cursor, the pointer, a node of its views, or a corner of a pane or of the window. Neither are the settings window's pages, which Lokyr's own plugins alone have.
Events
A plugin subscribes to the events that it hears; those that a capability guards need it.
| Event | When | Capability |
|---|---|---|
window-opened, window-closed | A window opens or closes | — |
window-focus | A window takes the keyboard's focus, or loses it | — |
tab-created, tab-closed, tab-activated, tab-moved | A tab opens, closes, shows or moves | — |
tab-changed | A tab's title, color, place or marks change | Its programs', progress' and agents' fields of process-read |
group-changed | A group of tabs is made, renamed, colored, folded or unfolded, takes or loses a tab, or goes; a read of the window's groups reports it · Since 1.3 | — |
session-changed | A session is made, renamed, switched to or from, or goes; a read of the sessions reports it · Since 1.5 | — |
broadcast-changed | A window's typed input goes to another set of panes, or a pane of it is left out or taken back in; a read of the window's broadcast reports it · Since 1.5 | — |
tab-bar-resized | The tab bar's column is dragged to another width | — |
pane-created, pane-closed, pane-focused, pane-moved | A pane opens, closes, takes the keyboard or moves. A tab closed and kept for Reopen Closed Tab tells pane-closed of each pane, whose decorations, gutter marks, cursor shown and searches Lokyr takes away; given back, it tells tab-created and pane-created as a tab opened anew | — |
pane-changed | A pane's title or header changes | process-read |
layout-changed | A tab's splits change | — |
viewport-changed | A pane's view scrolls or resizes, once a frame | — |
command-started, command-ended | A command of the shell starts or ends, of shell integration's marks | history-read, or process-read of no exit status · Since 1.4 |
pointer | The pointer moves over a pane's cells | pointer-read |
keys-changed | The keymap changes | — |
config-changed | The plugin's section of the config changes | — |
lines | A read of rows, read_lines, ends | terminal-read |
searched | A search, search, finds its matches | terminal-read |
answered | A question, ask_text, copy_theme, new_theme or convert_theme, is answered or cancelled | — |
saved | A file given to the save panel, save_file, is written, or not | — |
popup-closed | A popup that the plugin opened, open_popup, closes, of its command's status · Since 1.5 | — |
chosen | A question of buttons, ask_choice, is answered, or its window closes | — |
color-picked | A color is chosen in the color panel that the plugin showed, show_color_panel, as it moves | — |
color-panel-closed | The color panel that the plugin showed closes | — |
panel-closed | One of the plugin's panels closes | — |
page-shown, page-hidden | One of the plugin's pages of the settings window shows, or hides as another shows or the window closes; Lokyr's own plugins alone have pages | — |
timer | One of the plugin's timers fires | — |
double-tapped | The modifier that the plugin watches, watch_double_tap, is tapped twice, alone, from any app · Since 1.3 | global-hotkey |
package, packages-ended | A job of the packages' service tells a line, or ends | packages |
automation | A script or a shortcut asks something of Lokyr from outside it, of its id, the app that asks and its request, which the plugin answers by answer_automation; to the plugin alone · Since 1.6 | automation |
plugins-changed | A plugin is installed, updated, removed, turned off or on, starts or faults, or a capability's decision changes; or the installed plugins are taken anew, whatever their list holds, as of a package that Lokyr refused | packages |
settings-changed | The config applies anew, of other values, or a plugin of a config schema is installed, updated or removed | config |
themes-changed | The themes' list read, as Lokyr reads it off its main thread, or a theme added, removed or changed | — |
theme-changed | The theme in force resolves anew, of other colors: another theme named, its file saved, the appearance changed; or the theme that a view's themed node names does; theme_tokens reads its tokens | — |
<namespace>.<name> | A plugin's own event, which it emits of its namespace alone | — |
The views' events, as click, submit or toggle, come to the plugin's on_view_event of the view that it rendered, of no subscription.
Limits
Each plugin runs in a VM of its own, so a failing plugin never affects the terminal: it is disabled, and a notice tells it. The details are in Limits and isolation.
- Deadlines: 16 ms for
renderandapplies, 250 ms for a command, an event or a view's event, and a second for the activation, the entry's run included; past it, the call fails and the plugin faults. - Memory: 64 MB a plugin.
- Faults: a plugin that faults starts again after a second, then two; at its third fault within a minute, it stays off until it is turned on again.
- A call's writes and requests of the app's, which apply as it returns: 10 000 at most together.
- The panes that a plugin opens, by new tabs, splits, popups, windows and sessions together: 16 a call at most, and 64 a second of its calls together, as each is a shell of its own; past them, another fails. · Since 1.6
- Reads of rows: four under way at most; searches: 16 a call; images: four a call, 16 million pixels each.
- Cells of rows,
row_cells: 1000 rows at most a read, as an image's · Since 1.4. - Temporary files,
temp_file: a name of a text's extension,.txt,.log,.md,.json,.yaml,.yml,.toml,.diffor.patch; 8 MiB a file, 16 files and 32 MiB together; 32 MiB of writes at once, each 256 KiB at least, given back at 8 MiB a second; none of a call that only looks, asapplies· Since 1.4. - Timers: 64 at most, from 10 ms to a day.
- Programs' icons,
set_program_icons: 256 at most, each one of Lokyr's icons · Since 1.7. - Notices: one a second a plugin, a text of 1 to 1024 characters and a title of 100 at most.
- Questions,
ask_textandask_choice: one at a time a plugin, until its answer comes; a message of 1 to 256 characters, a detail of 1024 and a button's title of 64 at most, of no control character but the detail's line breaks nor one that hides the text around it. The alert of a plugin other than Lokyr's own names it. - Declarations: a plugin's commands, keys and menu items, 4096 at most together.
- Chains of commands that run commands: 16 deep and 256 runs at most.
- Data: a view nests 64 levels at most, and a value of data 64 too; texts of 16 MiB at most a call; numbers finite.
- State: the plugin's own file, 1 MiB at most.
Errors
A failed call answers nil and an error: its code, which never changes, its kind, as Luau names it, and its message. The hundreds tell the category.
| Code | Kind | Category | Meaning |
|---|---|---|---|
| 101 | not-found | Usage | No command of the name, or no window, tab or pane of the id |
| 102 | invalid-args | Usage | An argument that the command does not take |
| 103 | invalid-args | Usage | A required argument missing |
| 104 | invalid-args | Usage | An argument of another kind than its parameter's |
| 105 | invalid | Usage | A command's or a parameter's name that is not one |
| 106 | invalid | Usage | A command registered already |
| 107 | invalid | Usage | A schema that repeats a parameter, or whose default is of another kind |
| 108 | invalid | Usage | A binding whose keys, command or context is not one |
| 109 | invalid | Usage | A config that does not read, or whose values are not its keys' |
| 201 | failed | Failure | The command ran, and failed |
| 202 | failed | Failure | What an action needs is not there, as a font's family that is not installed |
| 301 | denied | Security | A command that the plugin's manifest does not declare |
| 302 | denied | Security | A capability that the request needs, which the plugin lacks |
| 401 | fault | Fault | A command that broke, as by a panic |