Skip to content

Commit 3134ed6

Browse files
add documentation
Co-authored-by: Max Petts <[email protected]> Signed-off-by: gilice <[email protected]>
1 parent ee8a30a commit 3134ed6

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# lapce-volt
2+
3+
This repository serves as a starting point for writing [Lapce](https://lapce.dev/) plugins in the [Rust Programming Language](https://www.rust-lang.org).
4+
If you haven't used Rust before, consider familiarizing yourself with the [documentation](https://doc.rust-lang.org/book/) .
5+
6+
## Getting started
7+
8+
- If not yet done, [install Rust](https://www.rust-lang.org/learn/get-started)
9+
- This template uses [cargo-make](https://github.com/sagiegurari/cargo-make) as a build system. Install it using `cargo install --force cargo-make`.
10+
- Generate your own repository based on this one by following the instructions [here](https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-repository-from-a-template).
11+
- [Clone it](https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository) locally
12+
- Ensure the wasi target is installed, using: `rustup target add wasm32-wasi`
13+
- Compile your addon by executing `cargo make dev` in the cloned directory. This will create a `bin/lapce-plugin-template.wasm` file.
14+
- Edit the extension's metadata in the `volt.toml` file.
15+
- Check the `activation` block. Here, you can configure when Lapce will load your plugin. The two corresponding settings, `language` and `workspace-contains` accept an array of RegExps.
16+
- Although this is **not recommended because of performance concerns**, to always load your extension, you can use `*`
17+
- Edit the `wasm` property to reflect the (relative) path of the built plugin.
18+
- Edit the `Cargo.toml` name property to match the `volt.toml` name property.
19+
- Lapce loads extensions that are placed inside its plugins folder.
20+
- If your filesystem supports symbolic links, symlink the plugin directory to `~/.local/share/lapce-stable/`, or `/Users/[USERNAME]/Library/Application Support/dev.lapce.Lapce-Stable/plugins` for Mac.
21+
- If it doesn't,
22+
- Make a folder in the plugins directory in the format of `author.plugin-name`, so for example `~/.local/share/lapce-stable/plugins/bob.awesome-plugin`
23+
- copy the forementioned `lapce-plugin-template.wasm` and the `volt.toml` files to this directory
24+
- Open Lapce, or, if already open, run the `Reload Window` command and check if your plugin appears in the sidebar.
25+
- If it does not, check that the relative path to the `.wasm` file is correct.
26+
27+
## Development
28+
29+
- The `src/main.rs` file provides plenty of comments to help you get started with writing your plugin.
30+
- You can configure the user-facing settings of the plugin in the `config` header of the `volt.toml` file.
31+
- The plugin has read and write access to it's own folder only. **DO NOT use this to persist data**, because it'll be deleted when Lapce updates your plugin.
32+
- You can quickly reload your extension without restarting lapce by clicking the cog icon besides the plugin's version in the UI and selecting `Reload Plugin`
33+
- To show user-facing notifications, use `PLUGIN_RPC.window_show_message()`. _You can't use `print!()` and `eprint!()` from plugins for logging._
34+
- The template includes [`anyhow`](https://github.com/dtolnay/anyhow) for pragmatic, flexible error handling.
35+
36+
## Publishing your plugin
37+
38+
- Before publishing, check that all information is correct in `volt.toml`.
39+
- If there is one, Lapce will show the `README.md` file as the plugin's description. You might want to write one to help with discoverability.
40+
- Register an account for [Lapce's extension directory](https://plugins.lapce.dev)
41+
- Install the `volts` tool, used for publishing extensions with `cargo install volts`
42+
- Create an api token on the website.
43+
- Build your plugin, and navigate to the directory of it (in the `plugins` directory, from where it's loaded)
44+
- Execute `volts publish`. Paste the token, that you've just created, in.
45+
- In a few minutes, your plugin should be up.

0 commit comments

Comments
 (0)