codemirror-languageserver 1.4.2 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -8,6 +8,10 @@ This plugin enables code completion, hover tooltips, and linter functionality by
|
|
|
8
8
|
|
|
9
9
|
## Usage
|
|
10
10
|
|
|
11
|
+
```
|
|
12
|
+
npm i codemirror-languageserver
|
|
13
|
+
```
|
|
14
|
+
|
|
11
15
|
``` js
|
|
12
16
|
import { languageServer } from 'codemirror-languageserver';
|
|
13
17
|
|
|
@@ -22,7 +26,7 @@ var view = new EditorView({
|
|
|
22
26
|
state: EditorState.create({
|
|
23
27
|
extensions: [
|
|
24
28
|
// ...
|
|
25
|
-
ls
|
|
29
|
+
ls,
|
|
26
30
|
// ...
|
|
27
31
|
]
|
|
28
32
|
})
|
|
@@ -33,6 +37,14 @@ var view = new EditorView({
|
|
|
33
37
|
|
|
34
38
|
Contributions are welcome.
|
|
35
39
|
|
|
40
|
+
## Real World Uses
|
|
41
|
+
|
|
42
|
+
https://user-images.githubusercontent.com/348107/120141150-c6bb9180-c1fd-11eb-8ada-9b7b7a1e4ade.mp4
|
|
43
|
+
|
|
44
|
+
| | |
|
|
45
|
+
| --- | --- |
|
|
46
|
+
| [Toph](https://toph.co) | Competitive programming platform |
|
|
47
|
+
|
|
36
48
|
## License
|
|
37
49
|
|
|
38
50
|
The library is available under the BSD (3-Clause) License.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
interface LanguageServerOptions {
|
|
2
|
+
serverUri: `ws://${string}` | `wss://${string}`;
|
|
3
|
+
rootUri: string;
|
|
4
|
+
documentUri: string;
|
|
5
|
+
languageId: string;
|
|
6
|
+
onConnect(): void;
|
|
7
|
+
onDisconnect(): void;
|
|
8
|
+
}
|
|
9
|
+
declare function languageServer(options: LanguageServerOptions): import("@codemirror/state").Extension[];
|
|
10
|
+
export { languageServer };
|
package/dist/index.js
CHANGED
|
@@ -46,14 +46,14 @@ class LanguageServerPlugin {
|
|
|
46
46
|
destroy() {
|
|
47
47
|
this.client.close();
|
|
48
48
|
}
|
|
49
|
-
request(
|
|
49
|
+
request(method, params, timeout) {
|
|
50
50
|
return this.client.request({ method, params }, timeout);
|
|
51
51
|
}
|
|
52
52
|
notify(method, params) {
|
|
53
53
|
return this.client.notify({ method, params });
|
|
54
54
|
}
|
|
55
55
|
async initialize({ documentText }) {
|
|
56
|
-
const { capabilities } = await this.request(
|
|
56
|
+
const { capabilities } = await this.request('initialize', {
|
|
57
57
|
capabilities: {
|
|
58
58
|
textDocument: {
|
|
59
59
|
hover: {
|
|
@@ -116,7 +116,7 @@ class LanguageServerPlugin {
|
|
|
116
116
|
uri: this.rootUri,
|
|
117
117
|
},
|
|
118
118
|
],
|
|
119
|
-
});
|
|
119
|
+
}, timeout * 3);
|
|
120
120
|
this.capabilities = capabilities;
|
|
121
121
|
this.notify('initialized', {});
|
|
122
122
|
this.notify('textDocument/didOpen', {
|
|
@@ -152,10 +152,10 @@ class LanguageServerPlugin {
|
|
|
152
152
|
if (!this.ready || !this.capabilities.hoverProvider)
|
|
153
153
|
return null;
|
|
154
154
|
this.sendChange({ documentText: view.state.doc.toString() });
|
|
155
|
-
const result = await this.request(
|
|
155
|
+
const result = await this.request('textDocument/hover', {
|
|
156
156
|
textDocument: { uri: this.documentUri },
|
|
157
157
|
position: { line, character },
|
|
158
|
-
});
|
|
158
|
+
}, timeout);
|
|
159
159
|
if (!result)
|
|
160
160
|
return null;
|
|
161
161
|
const { contents, range } = result;
|
|
@@ -178,14 +178,14 @@ class LanguageServerPlugin {
|
|
|
178
178
|
this.sendChange({
|
|
179
179
|
documentText: context.state.doc.toString(),
|
|
180
180
|
});
|
|
181
|
-
const result = await this.request(
|
|
181
|
+
const result = await this.request('textDocument/completion', {
|
|
182
182
|
textDocument: { uri: this.documentUri },
|
|
183
183
|
position: { line, character },
|
|
184
184
|
context: {
|
|
185
185
|
triggerKind,
|
|
186
186
|
triggerCharacter,
|
|
187
187
|
},
|
|
188
|
-
});
|
|
188
|
+
}, timeout);
|
|
189
189
|
if (!result)
|
|
190
190
|
return null;
|
|
191
191
|
const items = 'items' in result ? result.items : result;
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codemirror-languageserver",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.1",
|
|
4
4
|
"description": "Language Server Plugin for CodeMirror 6",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"prepare": "rollup
|
|
7
|
+
"prepare": "rollup -c rollup.config.js"
|
|
8
8
|
},
|
|
9
9
|
"author": {
|
|
10
10
|
"name": "Mahmud Ridwan",
|
|
@@ -30,12 +30,12 @@
|
|
|
30
30
|
"typescript": "^4.2.4"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@codemirror/autocomplete": "^0.
|
|
34
|
-
"@codemirror/lint": "^0.
|
|
35
|
-
"@codemirror/state": "^0.
|
|
36
|
-
"@codemirror/tooltip": "^0.
|
|
37
|
-
"@codemirror/view": "^0.
|
|
38
|
-
"@open-rpc/client-js": "^1.
|
|
33
|
+
"@codemirror/autocomplete": "^0.19.8",
|
|
34
|
+
"@codemirror/lint": "^0.19.3",
|
|
35
|
+
"@codemirror/state": "^0.19.8",
|
|
36
|
+
"@codemirror/tooltip": "^0.19.14",
|
|
37
|
+
"@codemirror/view": "^0.19.43",
|
|
38
|
+
"@open-rpc/client-js": "^1.7.1",
|
|
39
39
|
"vscode-languageserver-protocol": "^3.16.0"
|
|
40
40
|
},
|
|
41
41
|
"prettier": {
|