Skip to content

Touch ups to LSP and Tools packages #830

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

Merged
merged 3 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,9 @@ Analysis bin is what we currently call the OCaml code that does deeper language

We're happy to gather more resources over time here, including more in-depth getting started guides.

## Release
## Releasing the VSCode extension and standalone LSP package

_This below will automatically release the LSP package as well._

1. Bump the version to an _even minor_ version number in `package.json` and `server/package.json` and their lockfiles. It's very important that it's an even minor like `1.8.0`, and not `1.7.0`. This is because even minors are reserved for actual releases, and uneven minors for pre-releases. Commit and push the version bump.
2. Make sure @ryyppy is aware of your changes. He needs to sync them over to the vim plugin.
Expand All @@ -208,4 +210,8 @@ If that somehow does not work, you can do the above steps manually:
2. Go to the appropriate [VSCode Marketplace Publisher](https://marketplace.visualstudio.com/manage/publishers/chenglou92), select the three dots next to the extension name, and choose `Update`. Upload your `.vsix` there.
3. Not done! Make a new manual release [here](https://github.com/rescript-lang/rescript-vscode/releases), and make sure you attach the generated `.vsix` onto that new release as well. This is for folks who don't use the VSCode marketplace.

For beta releases, ask folks to try the `.vsix` from CI directly.
For beta releases, ask folks to use the pre-release version installable from the VSCode Marketplace.

## Releasing the `@rescript/tools` package

The tools package is released by bumping the version in `tools/package.json`, running `npm i` in the `tools/` folder, and then pushing those changes with the commit message `publish tools`.
10 changes: 0 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,16 +176,6 @@ A screenshot of the result:

![Shows the end result in VSCode, with ReScript related files nested under eachother appropriately.](https://user-images.githubusercontent.com/1457626/168123647-400e2f09-31e3-45a2-b74b-190c7c207446.png)

## ⌨️ Use with Other Editors

This repo also contains a language server that can power other editors. **However, the language server in this project is a pure implementation detail. We don't guarantee its stability for other editors' consumption** apart from Vim and Sublime Text.

Still, if you'd like to use this language-server with other editors:

- Get the release binaries from the Github Releases page.
- Unzip the `.vsix` and get the `server` folder. That's the only folder you need.
- The language server will be at `server/out/server.js`. Call it through node, and optionally pass `--stdio` if your editor doesn't support the default JSONRPC.

## 📰 Changelog

See [CHANGELOG](CHANGELOG.md)
Expand Down
2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "0.0.0",
"description": "ReScript's language-client",
"keywords": [],
"author": "chenglou",
"author": "ReScript Team",
"license": "MIT",
"dependencies": {
"vscode-languageclient": "8.1.0-next.5"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "rescript-vscode",
"displayName": "ReScript",
"description": "ReScript language support (official)",
"author": "chenglou",
"author": "ReScript Team",
"license": "MIT",
"version": "1.20.0",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ resciptls --stdio
```sh
ReScript Language Server

Usage: rescriptls [options]
Usage: rescript-ls [options]

Options:

Expand Down
2 changes: 1 addition & 1 deletion server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"name": "@rescript/lsp",
"description": "LSP server for ReScript",
"version": "1.20.0",
"author": "chenglou",
"author": "ReScript Team",
"license": "MIT",
"bin": {
"rescriptls": "./out/cli.js"
"rescript-ls": "./out/cli.js"
},
"keywords": [
"ReScript",
Expand Down
2 changes: 1 addition & 1 deletion server/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const args = process.argv.slice(2)

const help = `ReScript Language Server

Usage: rescriptls [options]
Usage: rescript-ls [options]

Options:

Expand Down
8 changes: 4 additions & 4 deletions tools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,27 @@ npm install --save-dev @rescript/tools
## CLI Usage

```sh
restools --help
rescript-tools --help
```

### Generate documentation

Print JSON:

```sh
restools doc src/EntryPointLibFile.res
rescript-tools doc src/EntryPointLibFile.res
```

Write JSON:

```sh
restools doc src/EntryPointLibFile.res > doc.json
rescript-tools doc src/EntryPointLibFile.res > doc.json
```

### Reanalyze

```sh
restools reanalyze --help
rescript-tools reanalyze --help
```

## Decode JSON
Expand Down
2 changes: 1 addition & 1 deletion tools/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"name": "@rescript/tools",
"description": "ReScript Tools",
"version": "0.1.0",
"author": "chenglou",
"author": "ReScript Team",
"license": "MIT",
"bin": {
"restools": "./src/Cli.bs.js"
"rescript-tools": "./src/Cli.bs.js"
},
"keywords": [
"ReScript",
Expand All @@ -17,6 +17,7 @@
"src/*.res",
"src/*.resi",
"analysis_binaries/",
"rescript.json",
"README.md"
],
"engines": {
Expand Down
3 changes: 1 addition & 2 deletions tools/rescript.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
"version": "0.1.0",
"sources": [
{
"dir": "src",
"public": ["RescriptTools"]
"dir": "src"
}
],
"suffix": ".bs.js",
Expand Down
6 changes: 3 additions & 3 deletions tools/src/Cli.res
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ let docHelp = `ReScript Tools

Output documentation to standard output

Usage: restools doc <FILE>
Usage: rescript-tools doc <FILE>

Example: restools doc ./path/to/EntryPointLib.res`
Example: rescript-tools doc ./path/to/EntryPointLib.res`

let help = `ReScript Tools

Usage: restools [command]
Usage: rescript-tools [command]

Commands:

Expand Down
1 change: 1 addition & 0 deletions tools/src/Cli.resi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

34 changes: 17 additions & 17 deletions tools/src/Tools_Docgen.res
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ type field = {
docstrings: array<string>,
signature: string,
optional: bool,
deprecated: option<string>,
deprecated?: string,
}

type constructor = {
name: string,
docstrings: array<string>,
signature: string,
deprecated: option<string>,
deprecated?: string,
}

@tag("kind")
type detail =
| @as("record") Record(array<field>)
| @as("variant") Variant(array<constructor>)
| @as("record") Record({items: array<field>})
| @as("variant") Variant({items: array<constructor>})

@tag("kind")
type rec item =
Expand All @@ -26,17 +26,17 @@ type rec item =
docstrings: array<string>,
signature: string,
name: string,
deprecated: option<string>,
deprecated?: string,
})
| @as("type")
Type({
id: string,
docstrings: array<string>,
signature: string,
name: string,
deprecated: option<string>,
deprecated?: string,
/** Additional documentation for constructors and record fields, if available. */
detail: option<detail>,
detail?: detail,
})
| @as("module") Module(docsForModule)
| @as("moduleAlias")
Expand All @@ -49,7 +49,7 @@ type rec item =
and docsForModule = {
id: string,
docstrings: array<string>,
deprecated: option<string>,
deprecated?: string,
name: string,
items: array<item>,
}
Expand Down Expand Up @@ -86,7 +86,7 @@ let decodeDepreacted = item => {

let decodeRecordFields = fields => {
open Js.Json
let fields = fields->Js.Array2.map(field => {
let items = fields->Js.Array2.map(field => {
switch field {
| Object(doc) => {
let name = doc->decodeStringByField("name")
Expand All @@ -98,32 +98,32 @@ let decodeRecordFields = fields => {
| _ => assert(false)
}

{name, docstrings, signature, optional, deprecated}
{name, docstrings, signature, optional, ?deprecated}
}

| _ => assert(false)
}
})
Record(fields)
Record({items: items})
}

let decodeConstructorFields = fields => {
open Js.Json
let fields = fields->Js.Array2.map(field => {
let items = fields->Js.Array2.map(field => {
switch field {
| Object(doc) => {
let name = doc->decodeStringByField("name")
let docstrings = doc->decodeDocstrings
let signature = doc->decodeStringByField("signature")
let deprecated = doc->decodeDepreacted

{name, docstrings, signature, deprecated}
{name, docstrings, signature, ?deprecated}
}

| _ => assert(false)
}
})
Variant(fields)
Variant({items: items})
}

let decodeDetail = detail => {
Expand Down Expand Up @@ -151,7 +151,7 @@ let rec decodeValue = item => {
let name = item->decodeStringByField("name")
let deprecated = item->decodeDepreacted
let docstrings = item->decodeDocstrings
Value({id, docstrings, signature, name, deprecated})
Value({id, docstrings, signature, name, ?deprecated})
}
and decodeType = item => {
let id = item->decodeStringByField("id")
Expand All @@ -163,7 +163,7 @@ and decodeType = item => {
| Some(field) => decodeDetail(field)->Some
| None => None
}
Type({id, docstrings, signature, name, deprecated, detail})
Type({id, docstrings, signature, name, ?deprecated, ?detail})
}
and decodeModuleAlias = item => {
open Js.Json
Expand All @@ -186,7 +186,7 @@ and decodeModule = item => {
| Some(Array(items)) => items->Js.Array2.map(item => decodeItem(item))
| _ => assert(false)
}
Module({id, name, docstrings, deprecated, items})
Module({id, name, docstrings, ?deprecated, items})
}
and decodeItem = item => {
open Js.Json
Expand Down
14 changes: 7 additions & 7 deletions tools/src/Tools_Docgen.resi
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,37 @@ type field = {
docstrings: array<string>,
signature: string,
optional: bool,
deprecated: option<string>,
deprecated?: string,
}
type constructor = {
name: string,
docstrings: array<string>,
signature: string,
deprecated: option<string>,
deprecated?: string,
}
type detail = Record(array<field>) | Variant(array<constructor>)
type detail = Record({items: array<field>}) | Variant({items: array<constructor>})
type rec item =
| Value({
id: string,
docstrings: array<string>,
signature: string,
name: string,
deprecated: option<string>,
deprecated?: string,
})
| Type({
id: string,
docstrings: array<string>,
signature: string,
name: string,
deprecated: option<string>,
detail: option<detail>,
deprecated?: string,
detail?: detail,
})
| Module(docsForModule)
| ModuleAlias({id: string, docstrings: array<string>, name: string, items: array<item>})
and docsForModule = {
id: string,
docstrings: array<string>,
deprecated: option<string>,
deprecated?: string,
name: string,
items: array<item>,
}
Expand Down
Loading