-
Notifications
You must be signed in to change notification settings - Fork 5
add documentation #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
algorithmiker
wants to merge
1
commit into
lapce-community:master
Choose a base branch
from
algorithmiker:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# lapce-volt | ||
|
||
This repository serves as a starting point for writing [Lapce](https://lapce.dev/) plugins in the [Rust Programming Language](https://www.rust-lang.org). | ||
If you haven't used Rust before, consider familiarizing yourself with the [documentation](https://doc.rust-lang.org/book/) . | ||
|
||
## Getting started | ||
|
||
- If not yet done, [install Rust](https://www.rust-lang.org/learn/get-started) | ||
- This template uses [cargo-make](https://github.com/sagiegurari/cargo-make) as a build system. Install it using `cargo install --force cargo-make`. | ||
- 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). | ||
- [Clone it](https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository) locally | ||
- Ensure the wasi target is installed, using: `rustup target add wasm32-wasi` | ||
- Compile your addon by executing `cargo make dev` in the cloned directory. This will create a `bin/lapce-plugin-template.wasm` file. | ||
- Edit the extension's metadata in the `volt.toml` file. | ||
- 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. | ||
- Although this is **not recommended because of performance concerns**, to always load your extension, you can use `*` | ||
- Edit the `wasm` property to reflect the (relative) path of the built plugin. | ||
- Edit the `Cargo.toml` name property to match the `volt.toml` name property. | ||
- Lapce loads extensions that are placed inside its plugins folder. | ||
algorithmiker marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- 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. | ||
- If it doesn't, | ||
- 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` | ||
- copy the forementioned `lapce-plugin-template.wasm` and the `volt.toml` files to this directory | ||
- Open Lapce, or, if already open, run the `Reload Window` command and check if your plugin appears in the sidebar. | ||
- If it does not, check that the relative path to the `.wasm` file is correct. | ||
|
||
## Development | ||
|
||
- The `src/main.rs` file provides plenty of comments to help you get started with writing your plugin. | ||
- You can configure the user-facing settings of the plugin in the `config` header of the `volt.toml` file. | ||
- 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. | ||
- 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` | ||
- To show user-facing notifications, use `PLUGIN_RPC.window_show_message()`. _You can't use `print!()` and `eprint!()` from plugins for logging._ | ||
- The template includes [`anyhow`](https://github.com/dtolnay/anyhow) for pragmatic, flexible error handling. | ||
|
||
## Publishing your plugin | ||
|
||
- Before publishing, check that all information is correct in `volt.toml`. | ||
- 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. | ||
- Register an account for [Lapce's extension directory](https://plugins.lapce.dev) | ||
- Install the `volts` tool, used for publishing extensions with `cargo install volts` | ||
- Create an api token on the website. | ||
- Build your plugin, and navigate to the directory of it (in the `plugins` directory, from where it's loaded) | ||
- Execute `volts publish`. Paste the token, that you've just created, in. | ||
- In a few minutes, your plugin should be up. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.