Reference implementation for community plugin authors. Demonstrates two injection kinds (InsertAfter and AddOption) in a single plugin, alongside a real generator. Not included in any production flow — exists purely as a learning resource.
Source: examples/example-plugin/plugin.go
| Field | Value |
|---|---|
| Plugin ID | example |
| Package | examples/example-plugin |
| Type | Example (not imported by the main binary) |
| Injected question ID | Type | Label | Default |
|---|---|---|---|
example.add_editorconfig |
ConfirmQuestion |
"Add .editorconfig for cross-IDE consistency?" | true |
Appends a new option to the stack OptionQuestion:
| Option value | Label | Next edge |
|---|---|---|
example.vscode_only |
"VSCode workspace only" | End (short-circuits the rest of the flow) |
This illustrates how a plugin can add a complete new branch to an existing question — selecting this option stops the flow at that point.
| Generator name | Version | Description |
|---|---|---|
example.editorconfig_writer |
0.1.0 |
Writes a sensible .editorconfig at project root |
Dependencies: base_project.
Files written:
| Path | Description |
|---|---|
.editorconfig |
Root-level .editorconfig with LF line endings, UTF-8, 2-space indent, trim whitespace |
Validators: Checks that .editorconfig exists after generation.
example.editorconfig_writer runs only when example.add_editorconfig is true. If the answer is false or missing, ResolveExtras returns nil.
When writing a new plugin, read this file alongside the source at examples/example-plugin/plugin.go. It covers:
- The full
Providerinterface implementation. - Combining two injection kinds in
Injections(). - Gating a generator on an injected answer in
ResolveExtras(). - The naming convention for all contributed IDs.
To scaffold a new plugin repository with a similar structure:
dot scaffold plugin-template