Lokyr
Documentation

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.

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.

CapabilityAllowsRisk
(none)Registering commands, and running those that the manifest declares; keymap, events, UI, themes, config, storage, logging, timers—
terminal-readReading screen and scrollback text, and the selectionHigh: the screen may show secrets
pty-writeSending input to the shellVery high
clipboard-readReading the clipboardHigh
clipboard-writeWriting to the clipboardMedium
notificationsShowing system notificationsLow
openOpening URLs and files with the system handlerMedium
process-spawnStarting processes; refused before 1.0.0, with a noticeVery high
net:<host>HTTP requests to the listed hosts, whatever their case; refused before 1.0.0, with a noticeHigh
fs-read:<path>, fs-write:<path>Access to the listed paths and to the paths under them, of whole components and no ..High
global-hotkeySystem-wide shortcuts, bindings of global: keys, the double taps of modifiers from any app, and quick windows, which slide in over every app'sMedium
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-readSeeing the keys typed before they reach the programVery high: a keylogger's power
history-readReading the commands that the shell ran and their output, which shell integration marks, and hearing their starts and ends of their exit statusesHigh: a password typed by mistake ends up there
process-readSeeing 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.7Medium: command lines can hold passwords
workspace-writeOpening, 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.6High: it can end every program, start shells, or move the keys typed to another pane
pane-viewThe 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.7Medium: a cleared scrollback is lost text
decorateDrawing over a pane: decorations, the gutter's marks, a search's matches and a held cursorMedium: a drawing over the text can show what the terminal does not hold
pointer-readThe pointer event: the cell under the pointer over the panes, and the modifiers heldLow
keep-awakeKeeping the system, or the system and the display, from idle sleepHigh: a display kept awake keeps the screen from locking
configThe 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' aloneVery high: a key written can change the program that a pane runs
packagesThe 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' aloneVery high: a plugin that installs another runs code of its choice
automationThe requests of scripts and shortcuts from outside Lokyr, the automation event, and their answers, answer_automation; Lokyr's own plugins' alone · Since 1.6Very high: a script's request can run any command and read a pane's text
user-commandsRunning 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.6Very high: pane.send-text types into the shell
appearance-writePreviewing a theme, a monospaced font family and a face's style, and naming the ones chosen in the config's [theme] and [font] familyMedium: 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.4High: 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.

SlotPluginsWhat it shows
tab-barOne, chosen in the configThe tab bar, in the titlebar, below it, at the window's bottom or down a column at its side
title-buttonsMany, three at most, more behind a menuA button of an icon right after the window's buttons, as a toggle of a state that the plugin keeps
status-barMany, on three sidesStatus 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-stripManyA thin strip across the panes' top, over them, as the programs' progress
pane-headerOneA 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.

EventWhenCapability
window-opened, window-closedA window opens or closes—
window-focusA window takes the keyboard's focus, or loses it—
tab-created, tab-closed, tab-activated, tab-movedA tab opens, closes, shows or moves—
tab-changedA tab's title, color, place or marks changeIts programs', progress' and agents' fields of process-read
group-changedA 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-changedA session is made, renamed, switched to or from, or goes; a read of the sessions reports it · Since 1.5—
broadcast-changedA 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-resizedThe tab bar's column is dragged to another width—
pane-created, pane-closed, pane-focused, pane-movedA 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-changedA pane's title or header changesprocess-read
layout-changedA tab's splits change—
viewport-changedA pane's view scrolls or resizes, once a frame—
command-started, command-endedA command of the shell starts or ends, of shell integration's markshistory-read, or process-read of no exit status · Since 1.4
pointerThe pointer moves over a pane's cellspointer-read
keys-changedThe keymap changes—
config-changedThe plugin's section of the config changes—
linesA read of rows, read_lines, endsterminal-read
searchedA search, search, finds its matchesterminal-read
answeredA question, ask_text, copy_theme, new_theme or convert_theme, is answered or cancelled—
savedA file given to the save panel, save_file, is written, or not—
popup-closedA popup that the plugin opened, open_popup, closes, of its command's status · Since 1.5—
chosenA question of buttons, ask_choice, is answered, or its window closes—
color-pickedA color is chosen in the color panel that the plugin showed, show_color_panel, as it moves—
color-panel-closedThe color panel that the plugin showed closes—
panel-closedOne of the plugin's panels closes—
page-shown, page-hiddenOne 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—
timerOne of the plugin's timers fires—
double-tappedThe modifier that the plugin watches, watch_double_tap, is tapped twice, alone, from any app · Since 1.3global-hotkey
package, packages-endedA job of the packages' service tells a line, or endspackages
automationA 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.6automation
plugins-changedA 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 refusedpackages
settings-changedThe config applies anew, of other values, or a plugin of a config schema is installed, updated or removedconfig
themes-changedThe themes' list read, as Lokyr reads it off its main thread, or a theme added, removed or changed—
theme-changedThe 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.

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.

CodeKindCategoryMeaning
101not-foundUsageNo command of the name, or no window, tab or pane of the id
102invalid-argsUsageAn argument that the command does not take
103invalid-argsUsageA required argument missing
104invalid-argsUsageAn argument of another kind than its parameter's
105invalidUsageA command's or a parameter's name that is not one
106invalidUsageA command registered already
107invalidUsageA schema that repeats a parameter, or whose default is of another kind
108invalidUsageA binding whose keys, command or context is not one
109invalidUsageA config that does not read, or whose values are not its keys'
201failedFailureThe command ran, and failed
202failedFailureWhat an action needs is not there, as a font's family that is not installed
301deniedSecurityA command that the plugin's manifest does not declare
302deniedSecurityA capability that the request needs, which the plugin lacks
401faultFaultA command that broke, as by a panic