examples/counter-plugin.
1. Create it
@scope/name, in lowercase. The command writes a counter folder (--path chooses another one); it does not need a NanoForge project around it.
2. Run it in the editor
"essential": true, for the few panels most work needs. When you save a source file, the editor reloads the plugin without reloading the page.
3. The manifest
nanoforge.manifest.json declares what the plugin adds. The editor reads it before running any code.
activation: the plugin’s code loads when its panel is first shown or its command first runs.widgets: a panel named Counter, docked bottom right by default.commandsandmenus: a command, listed in the Edit menu and in the command palette (Ctrl+Shift+P).settings: a number shown in Settings › Counter. Its full key is@acme/counter.step.
4. The code
src/index.ts exports the plugin. activate gets a context: the editor’s services, and subscriptions, where you put everything the plugin adds so it is removed with the plugin.
src/Panel.svelte is a Svelte 5 component. It receives the widget instance, and uses the editor’s own Button.
count is an ObservableValue from the SDK: Svelte reads it as a store ($count).
5. Try it
- Click Add twice, then press
Ctrl+Zwith the panel focused: the counter goes back by one. The step is in the History panel too. - Run Edit › Add to the counter, or find it in the command palette.
- Change Settings › Counter › Step to 5 and add again.
6. Install it without the dev mode
dist/ to ~/.nanoforge/editor/plugins/@acme/counter (every project) or to <project>/.nanoforge/plugins/@acme/counter (one project, and it can be committed with it). Reload the editor.
Where to go next
- A shortcut for the command:
contributes.keybindingsin the manifest. - A status bar item, a file template, a toolbar button: extension points.
- Reading and changing the game’s code: code and code generation.
- A plugin that only makes sense with an engine library: engine libraries.