Skip to content

Commit b53a50e

Browse files
authored
Merge pull request #69 from CodinGame/kaisalmen/demo-update
Demo and Build improvements
2 parents 8c9fede + 1e151aa commit b53a50e

13 files changed

Lines changed: 442 additions & 621 deletions

File tree

.eslintrc

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,26 @@
33
"es6": true,
44
"browser": true
55
},
6+
"parser": "@typescript-eslint/parser",
7+
"parserOptions": {
8+
"ecmaVersion": 2020,
9+
"sourceType": "module",
10+
"project": "./tsconfig.eslint.json"
11+
},
612
"globals": {
713
"Thenable": "readonly",
814
"VSCODE_VERSION": "readonly"
915
},
1016
"extends": [
1117
"@codingame"
1218
],
13-
"ignorePatterns": "vscode/**/*",
14-
"plugins": ["@typescript-eslint", "import", "unused-imports"]
15-
19+
"ignorePatterns": [
20+
"vscode/**/*",
21+
"dist/**/*"
22+
],
23+
"plugins": [
24+
"@typescript-eslint",
25+
"import",
26+
"unused-imports"
27+
]
1628
}

.vscode/settings.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"eslint.codeAction.showDocumentation": {
3+
"enable": true
4+
},
5+
"eslint.validate": [
6+
"javascript",
7+
"typescript"
8+
],
9+
"eslint.workingDirectories": [
10+
"**/src/**/*.ts",
11+
"./rollup/*.ts",
12+
"./*.ts"
13+
]
14+
}

README.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ The VSCode api is composed of:
1010
- If it's an important feature: we let the user implement it as they wish.
1111
- If it's some advanced features that don't make a lot of sense on Monaco (debug, tests...), it just throws an error when you try to use it.
1212

13-
1413
To implement by hands the optional features (file system, workspace folders, file...), you can use the `Services` namespace from `vscode/services`:
14+
1515
```typescript
1616
import { Services } from 'vscode/services'
1717
Services.install({
@@ -37,6 +37,7 @@ This library allows you to use a more convenient way using `StandaloneServices.i
3737
Also, monaco-editor doesn't provide good type for them, so this library does it.
3838

3939
Example:
40+
4041
```typescript
4142
import { StandaloneServices, INotificationService } from 'vscode/services'
4243

@@ -49,6 +50,7 @@ StandaloneServices.initialize({
4950
```
5051

5152
Additionally, this library exposes 10 modules that include the vscode version of some services (with some glue to make it work with monaco):
53+
5254
- Notifications: `vscode/service-override/notifications`
5355
- Dialogs: `vscode/service-override/dialogs`
5456
- Model / Editor: `vscode/service-override/modelEditor`
@@ -62,6 +64,7 @@ Additionally, this library exposes 10 modules that include the vscode version of
6264
- Token classification: `vscode/service-override/tokenClassification`
6365

6466
Usage:
67+
6568
```typescript
6669
import { StandaloneServices } from 'vscode/services'
6770
import getModelEditorServiceOverride from 'vscode/service-override/modelEditor'
@@ -106,12 +109,14 @@ The editors created using `monaco.editor.create` don't use the configuration fro
106109
This library exposes functions to create editors binded on the configuration:
107110

108111
before:
112+
109113
```typescript
110114
import * as monaco from 'monaco-editor'
111115
monaco.editor.create(...)
112116
```
113117

114118
after:
119+
115120
```typescript
116121
import { createConfiguredEditor } from 'vscode/monaco'
117122

@@ -143,6 +148,7 @@ vscode.languages.registerCompletionItemProvider(...)
143148

144149
There is a demo that showcases the service-override features. It allows to register contributions with the same syntaxes as in VSCode.
145150
It includes:
151+
146152
- Languages
147153
- Language configurations
148154
- VSCode themes
@@ -157,10 +163,13 @@ It includes:
157163
It also uses the `getJsonSchemas` function to register them on the monaco json worker and have autocomplete/hover on settings and keybindings.
158164

159165
From CLI run:
166+
160167
```bash
161168
cd demo
162169
npm ci
163-
npm start
170+
npm run start
171+
# OR: for vite debug output
172+
npm run start:debug
164173
```
165174

166175
### History
@@ -170,17 +179,20 @@ This project was mainly created to make the implementation of [monaco-languagecl
170179
monaco-languageclient uses [vscode-languageclient](https://www.npmjs.com/package/vscode-languageclient) which was built to run inside a VSCode extension. VSCode extensions communicate with the editor via an [API](https://www.npmjs.com/package/@types/vscode) they can import into their code.
171180

172181
[The VSCode api](https://code.visualstudio.com/api/references/vscode-api) exports:
182+
173183
- Some functions to interact with the IDE ([language feature registrations](https://code.visualstudio.com/api/references/vscode-api#languages), [command execution](https://code.visualstudio.com/api/references/vscode-api#commands)...)
174184
- A lot of utility classes (Range, Position...)
175185

176186
The first implementations of [monaco-languageclient](https://github.com/TypeFox/monaco-languageclient) were using a fake VSCode api implementation. The vscode-languageclient was hacked so the VSCode<->protocol object converters were mainly bypassed, so the fake VSCode api was receiving [Language Server Protocol](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/) objects. Then the objects were transformed using custom transformers into [Monaco](https://www.npmjs.com/package/monaco-editor) objects to communicate with the monaco api.
177187

178188
This approach has some disadvantages:
189+
179190
- There is a lot of code to transform LSP objects into Monaco objects
180191
- It's hard to follow the updates of VSCode and the language server protocol
181192
- It doesn't behave exactly the same as in VSCode
182193

183194
With this library, it would be possible to plug vscode-languageclient directly on top of monaco, monaco-languageclient still helps to do so by:
195+
184196
- Adding some tweaks to the VSCode LanguageClient (Removing unsupported features...)
185197
- Providing a default implementations of the required fallback services (`vscode/services`)
186198
- Providing some examples on how to build an app using it

0 commit comments

Comments
 (0)