README.md

 1# Slash Commands Example Extension
 2
 3This is an example extension showcasing how to write slash commands.
 4
 5See: [Extensions: Slash Commands](https://zed.dev/docs/extensions/slash-commands) in the Zed Docs.
 6
 7## Pre-requisites
 8
 9[Install Rust Toolchain](https://www.rust-lang.org/tools/install):
10
11```sh
12curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
13```
14
15## Setup
16
17```sh
18git clone https://github.com/zed-industries/zed.git
19cp -RL zed/extensions/slash-commands-example .
20
21cd slash-commands-example/
22
23# Update Cargo.toml to make it standalone
24cat > Cargo.toml << EOF
25[package]
26name = "slash_commands_example"
27version = "0.1.0"
28edition = "2021"
29license = "Apache-2.0"
30
31[lib]
32path = "src/slash_commands_example.rs"
33crate-type = ["cdylib"]
34
35[dependencies]
36zed_extension_api = "0.1.0"
37EOF
38
39curl -O https://raw.githubusercontent.com/rust-lang/rust/master/LICENSE-APACHE
40echo "# Zed Slash Commands Example Extension" > README.md
41echo "Cargo.lock" > .gitignore
42echo "target/" >> .gitignore
43echo "*.wasm" >> .gitignore
44
45git init
46git add .
47git commit -m "Initial commit"
48
49cd ..
50mv slash-commands-example MY-SUPER-COOL-ZED-EXTENSION
51zed $_
52```
53
54## Installation
55
561. Open the command palette (`cmd-shift-p` or `ctrl-shift-p`).
572. Launch `zed: install dev extension`
583. Select the extension folder created above
59
60## Test
61
62Open the assistant and type `/echo` and `/pick-one` at the beginning of a line.
63
64## Customization
65
66Open the `extensions.toml` file and set the `id`, `name`, `description`, `authors` and `repository` fields.
67
68Rename `slash-commands-example.rs` you'll also have to update `Cargo.toml`
69
70## Rebuild
71
72Rebuild to see these changes reflected:
73
741. Open Zed Extensions (`cmd-shift-x` or `ctrl-shift-x`).
752. Click `Rebuild` next to your Dev Extension (formerly "Slash Command Example")
76
77## Troubleshooting / Logs
78
79- MacOS: `tail -f ~/Library/Logs/Zed/Zed.log`
80- Linux: `tail -f ~/.local/share/zed/logs/Zed.log`
81
82## Documentation
83
84- [zed.dev docs: Extensions: Developing Extensions](https://zed.dev/docs/extensions/developing-extensions)
85- [zed.dev docs: Extensions: Slash Commands](https://zed.dev/docs/extensions/slash-commands)