Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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 document resource, 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 document resource. diagnostics reads the diagnostics, and request-symbols asks the language servers for document symbols. Neither needs a grant (Capabilities).
  • No shipped plugin targets it.

picker-ui

World: picker-ui.

  • dk calls key for 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/picker is the shipped plugin. A plugins/picker.wasm in the config directory replaces it.

plugin

World: plugin.

  • dk calls motion for word motions, keymap to resolve the bindings of the config, and command to run undo, redo, earlier and later.
  • The plugin calls the document resource and the history resource. dk lends the History for the length of one command.
  • plugins/keymap is the shipped plugin. A plugins/keymap.wasm in 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 as markers, query, changes, annotate, log and revision. 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 exec grant names its program (Capabilities).
  • plugins/vcs is the shipped plugin, for jj. A plugins/vcs.wasm in the config directory replaces it, and it gets no grant until your config pins it.