Skip to content

Commit 229d85c

Browse files
authored
Merge pull request #16 from nojaf/contributing
Add contributing.md
2 parents cf56514 + 5ee751c commit 229d85c

File tree

2 files changed

+100
-24
lines changed

2 files changed

+100
-24
lines changed

CONTRIBUTING.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Contributing to rescript-zed
2+
3+
## Developing
4+
5+
This guide covers local development for the rescript-zed extension. For more detailed information about Zed extension development, see the [official Zed documentation](https://zed.dev/docs/extensions/developing-extensions).
6+
7+
### Prerequisites
8+
9+
Before starting to develop this extension, make sure you have:
10+
11+
- [Rust installed via rustup](https://rustup.rs/) (required for Zed extensions)
12+
- Zed editor installed
13+
14+
**Note:** Rust must be installed via rustup. If you have Rust installed via homebrew or otherwise, installing dev extensions will not work.
15+
16+
### Development Workflow
17+
18+
When developing the extension, you can use it in Zed without needing to publish it by installing it as a _dev extension_.
19+
20+
1. **Clone this repository**
21+
22+
2. **Install the dev extension in Zed:**
23+
- Open Zed
24+
- Open the Extensions page (Cmd + Shift + P, then type "zed: extensions")
25+
- Click the `Install Dev Extension` button (or use the `zed: install dev extension` action)
26+
- Select the directory containing this extension
27+
28+
3. **Making changes:**
29+
- Edit the extension code as needed
30+
- You do **not** need to build anything manually before installing/reinstalling
31+
- After making changes, use the "Reinstall" button from the Extensions menu to reload your changes
32+
33+
4. **Sanity check (optional):**
34+
- You can run `cargo build` in the extension directory to verify the Rust code compiles
35+
- This is not required for (re)installing the extension, but can help catch compilation errors early
36+
37+
### Debugging
38+
39+
If you need to troubleshoot, here are some useful debugging tools:
40+
41+
**View Zed logs:**
42+
43+
```sh
44+
tail -f ~/Library/Logs/Zed/Zed.log
45+
```
46+
47+
Or use the `zed: open log` command from Zed.
48+
49+
**For more verbose debug output (recommended):**
50+
51+
Close Zed completely and relaunch it from the command line with:
52+
53+
```sh
54+
zed --foreground
55+
```
56+
57+
This will show more verbose INFO level logging in your terminal, including `println!` and `dbg!` output from your extension code. This is the preferred way to debug extensions during development.
58+
59+
**View language server logs:**
60+
61+
Open Cmd + Shift + P and find:
62+
63+
```
64+
dev: open language server logs
65+
```
66+
67+
### Using a Local Language Server Build
68+
69+
If you're also developing the ReScript language server locally, you can configure Zed to use your local build instead of the published version.
70+
71+
Add the following to your Zed settings (`zed: open settings file`):
72+
73+
```json
74+
{
75+
"lsp": {
76+
"rescript-language-server": {
77+
"binary": {
78+
"path": "/absolute-path/to/your/node-or-bun",
79+
"arguments": [
80+
"/path/to/your/rescript-vscode/server/out/cli.js",
81+
"--stdio"
82+
]
83+
}
84+
}
85+
}
86+
}
87+
```
88+
89+
Replace the paths with your actual local paths:
90+
- `path`: Path to your Node.js/Bun runtime (e.g., `/Users/username/.bun/bin/bun` or `/usr/local/bin/node`)
91+
- First argument: Path to your local language server CLI (e.g., `/Users/username/Projects/rescript-vscode/server/out/cli.js`)
92+
93+
**Note:** Make sure your local language server is built before using it. For rescript-vscode, this typically means running the build command in that repository first.
94+
95+
### Publishing Changes
96+
97+
If you already have the published version of the extension installed, it will be uninstalled automatically when you install the dev extension. The Extensions page will indicate that the upstream extension is "Overridden by dev extension".
98+
99+
To publish updates to the extension, follow the [Zed extension publishing guidelines](https://zed.dev/docs/extensions/developing-extensions#publishing-your-extension).

README.md

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -31,27 +31,4 @@ With `version` you can point to a specific npm version of the [@rescript/languag
3131

3232
## Developing
3333

34-
Zed and its support for extensions is being actively developed. The current workflow that can be used to build this extension locally and install it into Zed is:
35-
36-
Clone zed and build the `zed-extension` cli:
37-
38-
git clone [email protected]:zed-industries/zed.git
39-
cd zed
40-
cargo build --release --package extension_cli
41-
ln -sf "$(pwd -P)/target/release/zed-extension" /usr/local/bin/zed-extension
42-
43-
Build and install the extension locally
44-
45-
make build
46-
47-
Tail zed logs
48-
49-
tail -f ~/Library/Logs/Zed/Zed.log
50-
51-
After opening a ReScript file, open Cmd + Shift + P nav and find
52-
53-
language selector: toggle
54-
55-
And to see the language server logs, open Cmd + Shift + P nav and find
56-
57-
debug: open language server logs
34+
See [CONTRIBUTING.md](CONTRIBUTING.md) for instructions on how to develop this extension locally.

0 commit comments

Comments
 (0)