Skip to content

Commit

Permalink
WIP: Doc update, update versions, update to latest monaco-vscode-api,…
Browse files Browse the repository at this point in the history
… use monaco-editor as dependency designator
  • Loading branch information
kaisalmen committed Mar 14, 2024
1 parent 9b1b3cf commit 668bcd3
Show file tree
Hide file tree
Showing 30 changed files with 426 additions and 483 deletions.
50 changes: 15 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,20 @@
[![NPM Version](https://img.shields.io/npm/v/monaco-languageclient.svg)](https://www.npmjs.com/package/monaco-languageclient)
[![NPM Download](https://img.shields.io/npm/dt/monaco-languageclient.svg)](https://www.npmjs.com/package/monaco-languageclient)

Repository for [NPM module](https://www.npmjs.com/package/monaco-languageclient) to connect [Monaco editor](https://microsoft.github.io/monaco-editor/) with [language servers](https://microsoft.github.io/language-server-protocol/) and [NPM module](https://www.npmjs.com/package/vscode-ws-jsonrpc) which implements communication between a jsonrpc client and server over WebSocket.
This repository now multiple npm packages under under roof:

- [monaco-languageclient](https://www.npmjs.com/package/monaco-languageclient) to connect [Monaco editor](https://microsoft.github.io/monaco-editor/) with [language servers](https://microsoft.github.io/language-server-protocol/).
- [vscode-ws-jsonrpc](https://www.npmjs.com/package/vscode-ws-jsonrpc) which implements communication between a jsonrpc client and server over WebSocket.
- [monaco-editor-wrapper](https://www.npmjs.com/package/monaco-editor-wrapper) for building monaco editor application driven by configuration
- [monaco-editor-react](https://www.npmjs.com/package/@typefox/monaco-editor-react) puts a react cloack over `monaco-editor-wrapper`

Click [here](https://www.typefox.io/blog/teaching-the-language-server-protocol-to-microsofts-monaco-editor/) for a detail explanation how to connect the Monaco editor to your language server.

- [Monaco Language Client \& VSCode WebSocket Json RPC](#monaco-language-client--vscode-websocket-json-rpc)
- [Getting started](#getting-started)
- [Vite dev server](#vite-dev-server)
- [Using monaco-languageclient](#using-monaco-languageclient)
- [NEW with v7: Treemended monaco-editor](#new-with-v7-treemended-monaco-editor)
- [Overrides instructions](#overrides-instructions)
- [NEW with v8: Own monaco-editor-api package](#new-with-v8-own-monaco-editor-api-package)
- [Using services and extra packages from @codingame/monaco-vscode-api](#using-services-and-extra-packages-from-codingamemonaco-vscode-api)
- [textmate and monarch](#textmate-and-monarch)
- [Examples Overview](#examples-overview)
Expand Down Expand Up @@ -61,7 +65,7 @@ npm run build

### Vite dev server

Start the Vite dev server. It serves all client code at [localhost](http://localhost:8080). You can go to the [index.html](http://localhost:8080/index.html) and navigate to all client examples from there. You can edit the client example code directly (TypeScript) and Vite ensures it automatically made available:
Start the Vite dev server. It serves all client code at [localhost](http://localhost:20001). You can go to the [index.html](http://localhost:20001/index.html) and navigate to all client examples from there. You can edit the client example code directly (TypeScript) and Vite ensures it automatically made available:

```shell
npm run dev
Expand All @@ -77,39 +81,15 @@ npm run watch

## Using monaco-languageclient

TODO: Section needs to be overhauled

### NEW with v7: Treemended monaco-editor

Since version 2 (see [Important Project Changes](#important-project-changes)) of this library we rely on [@codingame/monaco-vscode-api](https://github.com/CodinGame/monaco-vscode-api) to supply the vscode API. It evolved substantially since then and thesedays allows to use many vscode only services with `monaco-editor`.

Earlier in 2023 we started to treemend an existing `monaco-editor` dependency via a postinstall script. This adds back monaco-editor code that was removed during bundling/threeshaking (*treemending*). See the detailed explanation [here](https://github.com/CodinGame/monaco-vscode-api#why). But, this introduced multiple problems.

#### Overrides instructions

With v7 we decided to use readily treemended version of monaco-editor called [@codingame/monaco-vscode-editor-api](https://www.npmjs.com/package/@codingame/monaco-vscode-editor-api), but this requires to add `overrides` (npm/pnpm) and `resolutions` (yarn) in your project. Setting these ensures that all dependencies to `monaco-editor` and `vscode` are aligned:

```yaml
"overrides": {
"monaco-editor": "npm:@codingame/monaco-vscode-editor-api@~3.1.1"
},
"resolutions": {
"monaco-editor": "npm:@codingame/monaco-vscode-editor-api@~3.1.1"
}
```

In the following table you can see the effect when using `npm list monaco-editor` (here the [angular client example](https://github.com/TypeFox/monaco-languageclient-ng-example.git) was used to demonstrate it):
### NEW with v8: Own monaco-editor-api package

| No overrides | With overrides |
| :---- | :---- |
| ![No overrides](./docs/images/no-overrides.png) | ![With overrides](./docs/images/with-overrides.png) |

With `overrides` or `resolutions` configured any child depndencies with a another `monaco-editor` version will chnaged to the one you enforce.

This means some extra-configuration work, but removes the need for any postinstall scripts which lead to multiple package manager problems. It is now also very clear what is used and needed. Please see [Monaco-editor / @codingame/monaco-vscode-api compatibility table](#monaco-editor--codingamemonaco-vscode-api-compatibility-table) for a complete overview.
Since version 2 (see [Important Project Changes](#important-project-changes)) of this library we rely on [@codingame/monaco-vscode-api](https://github.com/CodinGame/monaco-vscode-api) to supply the vscode API. It evolved substantially since then and thesedays allows to use many vscode only services with `monaco-editor`. With v6 and v7 we "treemend" used a "treemended" version of `monaco-editor` which brought back monaco-editor code that was removed during bundling/threeshaking (*treemending*). This left users with the need to define overrides / resolution which was problematic.
Therefore [monaco-vscode-editor-api](https://www.npmjs.com/package/@codingame/monaco-editor-wrapper) is now used and installed as an alias to monaco-editor because it provides the same api as the official monaco-editor.

### Using services and extra packages from @codingame/monaco-vscode-api

**TODO: Continue overhaul here**

The bespoke projects not only supplies the api, but it provides 100+ packages with additional services, default extensions and language packs. By default when initalizing `monaco-languageclient` via the required `initServices` the following services are always loaded:

- *languages* and model *services* (always added by `monaco-languagclient`)
Expand Down Expand Up @@ -336,12 +316,12 @@ loader.config({ monaco });
If you use pnpm, you have to add `vscode` / `@codingame/monaco-vscode-api` as direct dependency (see the [following table](#monaco-editor--codingamemonaco-vscode-api-compatibility-table)), otherwise the installation will fail.

```json
"vscode": "npm:@codingame/monaco-vscode-api@~3.1.1"
"vscode": "npm:@codingame/monaco-vscode-api@~3.1.2"
```

## Monaco-editor / @codingame/monaco-vscode-api compatibility table

[This information has been moved here](./docs/versions-and-history.md#monaco-editor--codingamemonaco-vscode-api-compatibility-table).
Please see [Version information and project History](./docs/versions-and-history.md#monaco-editor--codingamemonaco-vscode-api-compatibility-table) for a complete overview.

## Important Project Changes

Expand Down
10 changes: 5 additions & 5 deletions docs/versions-and-history.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

## Monaco-editor / @codingame/monaco-vscode-api compatibility table

The following table describes which version of **monaco-languageclient** and **@codingame/monaco-vscode-api** are compatible with a specific version of **monaco-editor**. The listing starts with version 2.0.0 because **@codingame/monaco-vscode-api** was introduced for the first time.
The following table describes which version of **monaco-languageclient** and **@codingame/monaco-vscode-api** are compatible with a specific version of **monaco-editor** and **vscode**. The listing starts with version 2.0.0 because **@codingame/monaco-vscode-api** was introduced for the first time.

| monaco-languageclient | monaco-vscode-api | monaco-vscode-editor-api | monaco-editor | release date | comment |
| monaco-languageclient | monaco-vscode-api / editor-api | vscode | monaco-editor | release date | comment |
| :---- | :---- | :--- | :--- | :--- | :--- |
| 8.0.0 | 2.0.1 | 2.0.1 | 0.45.0 | 2024-02-0x | `@codingame/monaco-vscode-editor-api` replaces `@codingame/monaco-editor-treemended` |
| 8.0.0 | 3.1.2 | 1.87.2 | 0.47.0 | 2024-03-1x | `@codingame/monaco-vscode-editor-api` replaces<br>`@codingame/monaco-editor-treemended`<br>`@codingame/monaco-vscode-api` implements its own versioning scheme |
| 7.3.0 | 1.85.0 | 1.85.0 | 0.45.0 | 2024-01-04 | |
| 7.2.0 | 1.83.16 | 1.83.16 | 0.44.0 | 2023-12-07 | |
| 7.1.0 | 1.83.12 | 1.83.12 | 0.44.0 | 2023-11-27 | |
Expand Down Expand Up @@ -45,9 +45,9 @@ The following table describes which version of **monaco-languageclient** and **@

## Important Project Changes

### Febuary 2024 (v8.0.0)
### March 2024 (v8.0.0)

`@codingame/monaco-editor-treemended` is replaced by self-standing `@codingame/monaco-vscode-editor-api`.
`@codingame/monaco-editor-treemended` is replaced by self-standing `@codingame/monaco-vscode-editor-api`. All service and editor related functions have been moved from `monaco-languageclient` to `monaco-editor-wrapper` which has been moved into this repository.

### October 2023 (v7.0.0)

Expand Down
Loading

0 comments on commit 668bcd3

Please sign in to comment.