|
1 | 1 | # Contributing
|
2 | 2 |
|
3 |
| -Thanks for your interest. Below is an informal spec of how the plugin's server communicates with the actual compiler. If you're a ReScript editor plugin implementor, you should probably read this to understand the various important nuances. |
| 3 | +Thanks for your interest. Below is an informal spec of how the plugin's server communicates with the actual compiler. If you're a ReScript editor plugin implementor, you should probably read this to understand the various important nuances and copy it. |
4 | 4 |
|
5 | 5 | ## Other Editors With Language-Server Support
|
6 | 6 |
|
@@ -80,6 +80,8 @@ The compiler log contains exactly the same things you'd see in a regular termina
|
80 | 80 | - The errors are indented 2 spaces
|
81 | 81 | - The extra `#Start` and `#Done` (which aren't indented).
|
82 | 82 |
|
| 83 | +A parser for the diagnostics is [here](https://github.com/rescript-lang/rescript-vscode/blob/0dbf2eb9cdb0bd6d95be1aee88b73830feecb5cc/server/src/utils.ts#L129-L329). |
| 84 | + |
83 | 85 | ### State 1
|
84 | 86 |
|
85 | 87 | Artifacts cleaning through `bsb -clean` removes `.compiler.log` and turns into state 1. If that's the case, remove the diagnostics in the editor too. One could argue that they should be kept, but that's misleading UX-wise, and harder to implement correctly.
|
@@ -113,17 +115,19 @@ The bad alternatives are:
|
113 | 115 |
|
114 | 116 | ## Running `bsb` in the Editor
|
115 | 117 |
|
116 |
| -**Don't** do that unless you've prompted the user. |
| 118 | +**Don't** do that unless you've prompted the user. This plugin currently prompts the user upon opening thr first the first file of a project. It's not great, but otherwise lots of folks forget to start a `bsb` in the terminal to see the freshest diagnostics. |
| 119 | + |
| 120 | +Drawbacks: |
117 | 121 |
|
118 |
| -- Running an implicit `bsb -w` automatically means you've acquired the build watch mode lockfile. The user won't be able to run his/her own `bsb -w` in the terminal. |
119 |
| -- Running a one-shot `bsb` doesn't conflict, but is a waste. It's also incorrect, as there might be external file system changes you're not detecting. |
120 |
| -- The build might be a step in a bigger build. The editor running `bsb` implicitly goes against that. |
121 |
| -- If you have multiple files with different project roots open, running all of the `bsb`s is too intense. |
| 122 | +- Running an implicit `bsb -w` means you've acquired the build watch mode lockfile. The user won't be able to run his/her own `bsb -w` in the terminal. |
| 123 | +- Running a one-shot `bsb` doesn't conflict, but is a waste. It's also incorrect, as there might be external file system changes you're not detecting, e.g. version control changes. |
| 124 | +- The build might be a step in a bigger build. The editor running `bsb -w` by itself might clash with that. |
| 125 | +- If you have multiple files with different project roots open, running all of the `bsb -w`s is too intense. |
122 | 126 |
|
123 | 127 | ## Format
|
124 | 128 |
|
125 | 129 | To find the location of `bsc.exe` to run the formatter:
|
126 |
| -- Search in the file's directory's `node_modules/bs-platform/{platform}/bsc.exe`. |
| 130 | +- Search in the file's directory's `node_modules/bs-platform/{platform}/bsc.exe`. If not found, recursively search upward (because [monorepos](https://github.com/rescript-lang/rescript-vscode/blob/0dbf2eb9cdb0bd6d95be1aee88b73830feecb5cc/server/src/utils.ts#L39-L45)). |
127 | 131 | - Do **not** directly use `node_modules/.bin/bsc` if you can help it. That's a Nodejs wrapper. Slow startup. We don't want our formatting to be momentarily stalled because some Nodejs cache went cold.
|
128 | 132 | - `platform` can be `darwin`, `linux`, `win32` or `freebsd`.
|
129 | 133 |
|
|
0 commit comments