Skip to content
DocsCommands

PluginsEarly

Commands

What a handler can return for the app to do: open a file, show a panel, start an agent.

From the plugin interface of gr 0.2.16 (API 0.1, 0.2, 0.3). gr plugin api commands prints it on your machine.

A handler returns a list of commands, each an object with a cmd field, and the app carries them out in order. $.editor.run(...) runs one at any other time.

open

open.code

Open a file inside the root in the code view, at line and column counted as a Pos is (from 0; the column in UTF-16 code units).

FieldKind
path requiredstring
lineint
columnint
whereheresplitvsplittab

open.node

Open a node's page.

FieldKind
id requiredstring

open.agent

Open an agent's page.

FieldKind
id requiredstring

open.terminal

Show one of the plugin's own terminals (terminal.open's id) where asked, the bottom when not said. The daemon sends it unasked with each terminal a plugin opens, so every one is shown; a plugin sends it again only to move one.

FieldKind
id requiredstring
wherebottomsplitvsplittab

Since API 0.2.

show

show.node

Show a node on the map.

FieldKind
id requiredstring

action

action

Run one of the editor's actions on the allowlist (actions). args are for agent.new only: { worktree }, a path the roster or worktrees.list knows, where the composer of a new agent opens for the person to write and send.

FieldKind
name requiredstring
argsrecord

message

message

Say something on the message line.

FieldKind
text requiredstring
levelinfowarningerror

panel

panel.show

Show one of the plugin's panels and focus it. With where = "tab" the panel opens as a tab of the centre beside files and agents, on a page's ground, the tab called by the panel's title beside its icon; with where = "dock", in the dock the layout or the manifest gives it. One view stands in one place: a panel moves out of the dock, float or tab it showed in to where it is asked for. With no where it is shown where it shows already, else where its manifest's dock says, and a [[panels]] table may say dock = "tab" (api 0.2). Closing its tab is hidden, as a dock that covers it is; the tab comes back after a restart, its last tree marked stale until the plugin answers, and closes, said once, where its plugin is gone.

FieldKind
panel requiredstring
wheredocktab

panel.hide

Hide one of the plugin's panels.

FieldKind
panel requiredstring

panel.toggle

Show or hide one of the plugin's panels.

FieldKind
panel requiredstring

float

float.show

Show one of the plugin's views as a float over the focused pane.

FieldKind
view requiredstring
anchorcursorcenter

float.hide

Put a float away.

FieldKind
view requiredstring

picker

picker.open

Open one of the plugin's pickers.

FieldKind
picker requiredstring
querystring

attach

attach

Attach a node, a file inside the root, an agent, or (with agents:write, since 0.2) text to the composer; the chip names the plugin.

FieldKind
context requiredattachment

layout

layout.use

Switch the window to one of its own named layouts (the [layouts.<name>] of its look's frame, as layout.next steps through them), or, with no name, back to the layout's own: its docks are shown and put away as that layout says, and panes, tabs and what they show stay. Honoured only in the answer to something the person did (a command, an act, a pick); from a timer, a write on the stream or any other event the app refuses it (command.refused) and says so. A name the window has no layout of is said, and nothing changes. The window's own named layouts are the allowlist: no other name switches anything.

FieldKind
namestring

Since API 0.2.

clipboard

clipboard.write

Put text on the person's clipboard; needs clipboard:write, at most 1 MiB.

FieldKind
text requiredstring

Since API 0.2.

edit

edit

Change the text of a document open in the editor, as one undo step named after the plugin and label; needs docs:write. The edits are against version's text, do not overlap, at most 1,000 and 1 MiB inserted. Applied only if the document is still at version; either way the plugin hears document.edited.

FieldKind
path requiredstring
version requiredint
edits requirededits
labelstring

Since API 0.2.

context

context.set

Set one of the plugin's own context keys, which a when clause tests: key is <plugin>.<name> (the plugin's name with - written _), value a bool, a number or a string of at most 256 bytes; null takes the key away. At most 64 keys a plugin; the editor keeps them until the plugin is switched off or removed.

FieldKind
key requiredstring
value requiredscalar

Since API 0.2.

layer

layer.enter

Put one of the plugin's own key layers ([[layers]]) on, above every key binding: honoured only in the answer to a command the person ran (a key, the palette, the command line, a click), in its hold or as its late result; from a timer, a write on the stream, an act or any other event it is refused (command.refused). While it is on, each of its keys runs its command with args [{...args, key}], the key in Vim notation; Escape, a key it does not bind (with leave = "other", and the key then goes on), its timeout or a change of the keys' mode leaves it, and the plugin hears layer.left.

FieldKind
layer requiredstring
argsobject

Since API 0.2.

layer.exit

Take the plugin's own key layer nearest the top off; from anywhere.

Since API 0.2.

These docs describe Graphide 0.2.16, the latest release. Something wrong or missing? Tell us onDiscord or at hello@graphide.com.