Skip to content

Commit 2bd7e38

Browse files
committed
Update some docs
1 parent a423637 commit 2bd7e38

File tree

5 files changed

+32
-23
lines changed

5 files changed

+32
-23
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ jobs:
5151
- run: npm run compile
5252

5353
# These 2 runs (or just the second?) are for when you have opam dependencies. We don't.
54-
# Don't add deps. But if you ever do, un-comment these
55-
# - run: opam pin add rescript-editor-support.dev . --no-action
54+
# Don't add deps. But if you ever do, un-comment these and add an .opam file.
55+
# - run: opam pin add rescript-editor-analysis.dev . --no-action
5656
# - run: opam install . --deps-only --with-doc --with-test
5757

5858
- name: Build and test

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ Fixes:
66
- Hover on components in interface files.
77

88
Features:
9-
- Show Outline
9+
- Show Outline!
1010
- Show References!
11-
- Hover now supports markdown docs!
11+
- Hover now supports markdown docs.
1212
- Hover on labels in component functions with compiler version 9.1, and labels with type annotation.
1313
- Don't show file path on hover and autocomplete (cleaner).
1414
- Autocomplete for props in JSX components.

CONTRIBUTING.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ Thanks for your interest. Below is an informal spec of how the plugin's server c
1717
├── src
1818
│ └── server.ts // Language Server entry point
1919
└── analysis_binaries // Prod-time platform-specific analysis binaries
20+
├── darwin
21+
├── linux
22+
└── win32
2023
```
2124

2225
## Install Dependencies
@@ -31,6 +34,7 @@ Thanks for your interest. Below is an informal spec of how the plugin's server c
3134
- `cd analysis && make`.
3235

3336
## Test
37+
3438
- Open VS Code to this folder.
3539
- Switch to the Debug viewlet (command palette -> View: Show Run and Debug).
3640
- Select `Client + Server` from the drop down, launch it (green arrow):
@@ -48,7 +52,7 @@ Thanks for your interest. Below is an informal spec of how the plugin's server c
4852
<img width="359" alt="image" src="https://user-images.githubusercontent.com/1909539/97448639-19db0800-18ee-11eb-875a-d17cd1b141d1.png">
4953
- For the native analysis binary tests: `cd analysis && make test`.
5054

51-
### Change the Grammar
55+
## Change the Grammar
5256

5357
The _real_ source of truth for our grammar is at https://github.com/rescript-lang/rescript-sublime. We port that `sublime-syntax` grammar over to this weaker TextMate language grammar for VSCode and the rest. There are some subtle differences between the 2 grammars; currently we manually sync between them.
5458

@@ -58,14 +62,10 @@ For more grammar inspirations, check:
5862
- [TypeScript's grammar](https://github.com/microsoft/TypeScript-TmLanguage/blob/a771bc4e79deeae81a01d988a273e300290d0072/TypeScript.YAML-tmLanguage)
5963
- [Writing a TextMate Grammar: Some Lessons Learned](https://www.apeth.com/nonblog/stories/textmatebundle.html)
6064

61-
### Snippets
65+
## Snippets
6266

6367
Snippets are also synced from https://github.com/rescript-lang/rescript-sublime. VSCode snippets docs [here](https://code.visualstudio.com/api/references/contribution-points#contributes.snippets).
6468

65-
### Autocomplete, Jump To Definition, Type Hint, Etc.
66-
67-
These are taken care of by the binary at [rescript-editor-support](https://github.com/rescript-lang/rescript-editor-support). We just invoke it in `RescriptEditorSupport.ts`.
68-
6969
## Binary Invocation
7070

7171
We call a few binaries and it's tricky to call them properly cross-platform. Here are some tips:
@@ -76,6 +76,10 @@ We call a few binaries and it's tricky to call them properly cross-platform. Her
7676
- `execFile` does not work on windows for batch scripts, which is what Node scripts are wrapped in. Use `exec`. See more [here](https://github.com/rescript-lang/rescript-vscode/blob/8fcc1ab428b8225c97d2c9a5b8e3a782c70d9439/server/src/utils.ts#L110).
7777
- Thankfully, many of our binaries are native, so we can keep using `execFile` most of the time.
7878

79+
## General Coding Guidance
80+
81+
- `server/` is a standalone folder that can be vendored by e.g. Vim and Sublime Text. Keep it light, don't add deps unless absolutely necessarily, and don't accidentally use a runtime dep from the top level `package.json`.
82+
7983
## Rough Description Of How The Plugin Works
8084

8185
### Editor Diagnostics
@@ -167,3 +171,5 @@ Currently the release is vetted and done by @chenglou.
167171
- Download and unzip the 3 platforms' production binaries from the Github CI. Put them into `server/analysis_binaries`.
168172
- Use `vsce publish` to publish. Official VSCode guide [here](https://code.visualstudio.com/api/working-with-extensions/publishing-extension). Only @chenglou has the publishing rights right now.
169173
- Not done! Make a new manual release [here](https://github.com/rescript-lang/rescript-vscode/releases); use `vsce package` to package up a standalone `.vsix` plugin and attach it onto that new release. This is for folks who don't use the VSCode marketplace.
174+
175+
For beta releases, we just do the last step and ask folks to try it.

analysis/src/Cli.ml

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,30 @@ let help =
22
{|
33
**Private CLI For rescript-vscode usage only**
44

5-
Examples:
5+
API examples:
66
./rescript-editor-analysis.exe complete src/MyFile.res 0 4 currentContent.res
77
./rescript-editor-analysis.exe definition src/MyFile.res 9 3
8-
./rescript-editor-analysis.exe dump src/MyFile.res src/MyFile2.res
98
./rescript-editor-analysis.exe documentSymbol src/Foo.res
109
./rescript-editor-analysis.exe hover src/MyFile.res 10 2
1110
./rescript-editor-analysis.exe references src/MyFile.res 10 2
11+
12+
Dev-time examples:
13+
./rescript-editor-analysis.exe dump src/MyFile.res src/MyFile2.res
1214
./rescript-editor-analysis.exe test src/MyFile.res
1315

14-
Note: coordinates are zero-based, so the first position is 0 0.
16+
Note: positions are zero-indexed (start at 0 0), following LSP.
17+
https://microsoft.github.io/language-server-protocol/specification#position
1518

1619
Options:
17-
complete: compute autocomplete for MyFile.res at line 0 and column 4,
20+
completion: compute autocomplete for MyFile.res at line 0 and column 4,
1821
where MyFile.res is being edited and the editor content is in file current.res.
1922

20-
./rescript-editor-analysis.exe complete src/MyFile.res 0 4 current.res
23+
./rescript-editor-analysis.exe completion src/MyFile.res 0 4 current.res
2124

2225
definition: get definition for item in MyFile.res at line 10 column 2:
2326

2427
./rescript-editor-analysis.exe definition src/MyFile.res 10 2
2528

26-
dump: for debugging, show all definitions and hovers for MyFile.res and MyFile.res:
27-
28-
./rescript-editor-analysis.exe dump src/Foo.res src/MyFile.res
29-
3029
documentSymbol: get all symbols declared in MyFile.res
3130

3231
./rescript-editor-analysis.exe documentSymbol src/MyFile.res
@@ -39,15 +38,19 @@ Options:
3938

4039
./rescript-editor-analysis.exe references src/MyFile.res 10 2
4140

41+
dump: for debugging, show all definitions and hovers for MyFile.res and MyFile.res:
42+
43+
./rescript-editor-analysis.exe dump src/Foo.res src/MyFile.res
44+
4245
test: run tests specified by special comments in file src/MyFile.res
4346

4447
./rescript-editor-analysis.exe test src/src/MyFile.res
4548
|}
4649

4750
let main () =
4851
match Array.to_list Sys.argv with
49-
| [_; "complete"; path; line; col; currentFile] ->
50-
Commands.complete ~path ~line:(int_of_string line) ~col:(int_of_string col)
52+
| [_; "completion"; path; line; col; currentFile] ->
53+
Commands.completion ~path ~line:(int_of_string line) ~col:(int_of_string col)
5154
~currentFile
5255
| [_; "definition"; path; line; col] ->
5356
Commands.definition ~path ~line:(int_of_string line)

analysis/src/Commands.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ let dump files =
3333
in
3434
print_endline result)
3535

36-
let complete ~path ~line ~col ~currentFile =
36+
let completion ~path ~line ~col ~currentFile =
3737
let uri = Uri2.fromLocalPath path in
3838
let result =
3939
match ProcessCmt.getFullFromCmt ~uri with
@@ -239,7 +239,7 @@ let test ~path =
239239
let line = line + 1 in
240240
let col = len - mlen - 3 in
241241
close_out cout;
242-
complete ~path ~line ~col ~currentFile;
242+
completion ~path ~line ~col ~currentFile;
243243
Sys.remove currentFile
244244
| _ -> ());
245245
print_newline ())

0 commit comments

Comments
 (0)