Skip to content

Commit ea90731

Browse files
authored
Merge pull request #19 from CodinGame/add-missing-apis
Rework, implement missing api, use more code from vscode
2 parents 55d570d + 968d805 commit ea90731

21 files changed

Lines changed: 2723 additions & 2660 deletions

.eslintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"browser": true
55
},
66
"globals": {
7-
"Thenable": "readonly"
7+
"Thenable": "readonly",
8+
"VSCODE_VERSION": "readonly"
89
},
910
"extends": [
1011
"@codingame"

README.md

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,40 @@ The VSCode api is composed of:
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

1313

14-
To implement by hands the optional features (type hierarchy, call hierarchy...), you can use the `Services` namespace from `vscode/services`:
14+
To implement by hands the optional features (file system, workspace folders, file...), you can use the `Services` namespace from `vscode/services`:
1515
```typescript
1616
import { Services } from 'vscode/services'
1717
Services.install({
18-
languages: {
19-
registerTypeHierarchyProvider (documentSelector, provider) {
20-
...
21-
}
22-
}
18+
workspace: {
19+
workspaceFolders: ...,
20+
createFileSystemWatcher (documentSelector, provider) {
21+
...
22+
},
23+
onDidSaveTextDocument
24+
},
25+
window: {
26+
withProgress: ...
27+
}
2328
})
2429
```
2530

31+
Also, monaco-editor use `standalone` versions or the vscode services, which are much simpler.
2632

33+
You may want to provide your custom implementations of them, especially for: `textModelService`, `codeEditorService` and `notificationService`. To do so, you can provide them as the third parameter while creating your first editor.
34+
This library allows you to use a more convenient way using `StandaloneService.initialize`.
35+
Also, monaco-editor doesn't provide good type for them, so this library does it.
36+
37+
Example:
38+
```
39+
import { StandaloneService, INotificationService } from 'vscode/services'
40+
41+
class MyCustomNotificationService implements INotificationService { ... }
42+
StandaloneService.initialize({
43+
get [INotificationService.toString()] () {
44+
return new MyCustomNotificationService(...)
45+
}
46+
})
47+
```
2748

2849
### Installation
2950

package-lock.json

Lines changed: 1345 additions & 1299 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@
3838
],
3939
"scripts": {
4040
"build": "rm -rf dist/ && npm run lint && npm run compile && npm run generate-types",
41-
"compile": "rollup --config rollup/rollup.config.ts --configPlugin 'typescript={tsconfig: `tsconfig.rollup.json`}'",
42-
"preprepare": "./scripts/install-vscode ${npm_package_config_vscode_version}",
41+
"compile": "rollup --config rollup/rollup.config.ts --configPlugin 'typescript={tsconfig: `tsconfig.rollup.json`}' --vscode-version ${npm_package_config_vscode_version}",
42+
"preprepare": "./scripts/install-vscode",
4343
"lint": "eslint --ext ts src",
4444
"generate-types": "tsc --project tsconfig.types.json && rollup --config rollup/rollup.types.config.ts --configPlugin 'typescript={tsconfig: `tsconfig.rollup.json`}' && rm -rf ./dist/types",
4545
"release": "node --loader ts-node/esm release.ts ${npm_package_config_vscode_version}"
4646
},
4747
"config": {
4848
"vscode": {
49-
"version": "1.68.0"
49+
"version": "1.67.0"
5050
}
5151
},
5252
"devDependencies": {
@@ -59,10 +59,11 @@
5959
"@codingame/tsconfig": "^1.0.5",
6060
"@octokit/rest": "^18.12.0",
6161
"@rollup/plugin-node-resolve": "^13.3.0",
62+
"@rollup/plugin-replace": "^4.0.0",
6263
"@rollup/plugin-typescript": "^8.3.2",
6364
"@types/babel__core": "^7.1.19",
6465
"@types/semver": "^7.3.10",
65-
"@types/vscode": "^1.68.0",
66+
"@types/vscode": "~1.67.0",
6667
"@typescript-eslint/eslint-plugin": "^5.27.1",
6768
"@typescript-eslint/parser": "^5.27.1",
6869
"eslint": "^8.17.0",

0 commit comments

Comments
 (0)