API
The API of a plugin is one WIT file, wit/editor.wit, which is the package ductus:editor@0.1.1.
A plugin is a component that implements one or more of its worlds.
dk loads a plugin only when each ductus:editor name that it imports or exports has the minor version of dk and a patch that is not above the patch of dk.
A plugin built for 0.1.0 loads.
dk refuses any other plugin before it runs any of its code, with one warning.
A plugin with more than one role includes the world of each role in its own world. A call to a plugin stops after 100 ms, and a plugin cannot grow past 64 MiB of memory. A plugin that traps is unloaded, and dk shows one warning (Plugins).
Each part below gives the world, what dk calls, what the plugin calls, and the shipped plugin that targets it. The interfaces that a world uses are in the file, and the links go to them.
hooks
World: hooks.
- dk calls the five Hooks of
document-hooks: opened, focused, will save, saved and closed. A Hook cannot stop or change the event. - The plugin calls the methods of the
documentresource, which read text by grapheme. - No shipped plugin targets it.
lsp-client
World: lsp-client.
- dk calls the three Hooks of
lsp-hooks: a language server attached, diagnostics changed and the reply to a request for symbols. - The plugin calls the
documentresource.diagnosticsreads the diagnostics, andrequest-symbolsasks the language servers for document symbols. Neither needs a grant (Capabilities). - No shipped plugin targets it.
picker-ui
World: picker-ui.
- dk calls
keyfor each key in a picker. The plugin answers with the row to select and one action: stay, accept, accept in a new view, close or edit the query. - The plugin calls nothing: dk keeps the list and draws it, so no file name reaches the plugin.
plugins/pickeris the shipped plugin. Aplugins/picker.wasmin the config directory replaces it.
plugin
World: plugin.
- dk calls
motionfor word motions,keymapto resolve the bindings of the config, andcommandto runundo,redo,earlierandlater. - The plugin calls the
documentresource and thehistoryresource. dk lends the History for the length of one command. plugins/keymapis the shipped plugin. Aplugins/keymap.wasmin the config directory replaces it, so a replacement must know the names that dk gives it, such as the word motions.
vcs-provider
World: vcs-provider.
- dk calls the functions of
vcs, such asmarkers,query,changes,annotate,logandrevision. They name the marker directories of a repository and the commands that give the base text of a file, its changes and its blame. - The plugin calls nothing and runs no process.
dk runs the command, and only when the
execgrant names its program (Capabilities). plugins/vcsis the shipped plugin, for jj. Aplugins/vcs.wasmin the config directory replaces it, and it gets no grant until your config pins it.