Prerequisites
- OpenIDEA installed.
- Rust through rustup.
openidea-plugin buildadds thewasm32-wasip2target through rustup if it is missing; you can also add it yourself withrustup target add wasm32-wasip2.
1
Install the openidea-plugin tool
main branch. To match a released IDE, add --tag v<version> (for example --tag v0.1.40). Each release also attaches a Linux x64 binary, openidea-plugin-linux-x86_64.gz.openidea-plugin --version prints the tool version and the plugin API it checks against.2
Scaffold a plugin
command template (the default) writes:The id is
<publisher>.<name>. The publisher part (acme) is what you sign with when you publish; without --id the id is derived from the folder name. --name sets the display name.The SDK dependency points at this repository at the tool’s release tag ({ git = "https://github.com/l0ng-ai/openidea", tag = "v…" }). Pass --sdk <path to sdk/rust/openidea-plugin> to use a local checkout instead.Other templates: --template theme, --template icon-theme, --template language. They need no code.3
Run the unit tests
4
Build the component
cargo build --release --target wasm32-wasip2, copies the result to dist/plugin.wasm (the manifest’s wasm path) and then runs openidea-plugin check, which validates the package exactly as installing would and prints what the user will be asked to grant:openidea-plugin build --debug for a debug build.5
Link the folder into the IDE
link adds the folder to links.json in the IDE’s plugins directory. Linked plugins are read from the folder itself, so you never reinstall while developing. openidea-plugin links lists linked folders and openidea-plugin unlink removes one.The plugins directory is
$OPENIDEA_PLUGINS_DIR, or ai.l0ng.openidea/plugins in your system’s app data directory. A development build of OpenIDEA from source uses its own data directory: point OPENIDEA_PLUGINS_DIR at its plugins folder when you link. See Data directories.6
Allow it and run a command
- Open Settings › Plugins (
⌘,on macOS,Ctrl+Alt+Son Windows/Linux). The plugin is listed under Linked for development with the status Needs permission. - Select it and click Review Permissions…, then Allow in the Allow Hello to run? dialog.
- Open Find Action (
⌘⇧A/Ctrl+Shift+A) and run Hello: Say Hello. A notification says Hello #1 from Hello!. - Open any file and run Hello: Line Count of Active File. The command returns text, which the IDE shows to you.
The edit loop
- Change
src/lib.rs(orplugin.toml). - Run
openidea-plugin build. - In Settings › Plugins, select the plugin and click the Reload from disk button in its details, or run the Reload Plugins action from Find Action.
What is in the code
plugin.tomldeclares the commands ([[contributes.commands]]), so they appear in Find Action before the code is loaded.run_commandreceives the command id and the invocation context (the window’s project and focused editor).greetingslives in the instance and resets when the plugin is unloaded after being idle. Keep what must survive inhost::storage(see Lifecycle and events).- Reading the editor needs the
editor.readcapability. Without it,editor.document()returnsError::Denied.
Next steps
- Manifest: every field of
plugin.toml. - Commands and actions: menus, shortcuts,
whenclauses and command arguments. - Example plugins: working plugins to copy from.
- Packaging and signing: turn the folder into an
.oiplugin.