codemirror-languageserver 1.5.1 → 1.6.0
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/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import * as LSP from 'vscode-languageserver-protocol';
|
|
1
2
|
interface LanguageServerOptions {
|
|
2
3
|
serverUri: `ws://${string}` | `wss://${string}`;
|
|
3
|
-
rootUri: string;
|
|
4
|
+
rootUri: string | null;
|
|
5
|
+
workspaceFolders: LSP.WorkspaceFolder[] | null;
|
|
4
6
|
documentUri: string;
|
|
5
7
|
languageId: string;
|
|
6
8
|
}
|
package/dist/index.js
CHANGED
|
@@ -12,12 +12,14 @@ const CompletionItemKindMap = Object.fromEntries(Object.entries(CompletionItemKi
|
|
|
12
12
|
const useLast = (values) => values.reduce((_, v) => v, '');
|
|
13
13
|
const serverUri = Facet.define({ combine: useLast });
|
|
14
14
|
const rootUri = Facet.define({ combine: useLast });
|
|
15
|
+
const workspaceFolders = Facet.define({ combine: useLast });
|
|
15
16
|
const documentUri = Facet.define({ combine: useLast });
|
|
16
17
|
const languageId = Facet.define({ combine: useLast });
|
|
17
18
|
class LanguageServerPlugin {
|
|
18
19
|
constructor(view) {
|
|
19
20
|
this.view = view;
|
|
20
21
|
this.rootUri = this.view.state.facet(rootUri);
|
|
22
|
+
this.workspaceFolders = this.view.state.facet(workspaceFolders);
|
|
21
23
|
this.documentUri = this.view.state.facet(documentUri);
|
|
22
24
|
this.languageId = this.view.state.facet(languageId);
|
|
23
25
|
this.documentVersion = 0;
|
|
@@ -31,6 +33,11 @@ class LanguageServerPlugin {
|
|
|
31
33
|
this.initialize({
|
|
32
34
|
documentText: this.view.state.doc.toString(),
|
|
33
35
|
});
|
|
36
|
+
this.transport.connection.addEventListener('message', (message) => {
|
|
37
|
+
const data = JSON.parse(message.data);
|
|
38
|
+
if (data.method && data.id)
|
|
39
|
+
this.processRequest(data);
|
|
40
|
+
});
|
|
34
41
|
}
|
|
35
42
|
update({ docChanged }) {
|
|
36
43
|
if (!docChanged)
|
|
@@ -110,12 +117,7 @@ class LanguageServerPlugin {
|
|
|
110
117
|
initializationOptions: null,
|
|
111
118
|
processId: null,
|
|
112
119
|
rootUri: this.rootUri,
|
|
113
|
-
workspaceFolders:
|
|
114
|
-
{
|
|
115
|
-
name: 'root',
|
|
116
|
-
uri: this.rootUri,
|
|
117
|
-
},
|
|
118
|
-
],
|
|
120
|
+
workspaceFolders: this.workspaceFolders,
|
|
119
121
|
}, timeout * 3);
|
|
120
122
|
this.capabilities = capabilities;
|
|
121
123
|
this.notify('initialized', {});
|
|
@@ -231,6 +233,13 @@ class LanguageServerPlugin {
|
|
|
231
233
|
options,
|
|
232
234
|
};
|
|
233
235
|
}
|
|
236
|
+
processRequest({ id }) {
|
|
237
|
+
this.transport.connection.send(JSON.stringify({
|
|
238
|
+
jsonrpc: '2.0',
|
|
239
|
+
id,
|
|
240
|
+
result: null
|
|
241
|
+
}));
|
|
242
|
+
}
|
|
234
243
|
processNotification(notification) {
|
|
235
244
|
try {
|
|
236
245
|
switch (notification.method) {
|
|
@@ -272,6 +281,7 @@ function languageServer(options) {
|
|
|
272
281
|
let plugin = null;
|
|
273
282
|
return [
|
|
274
283
|
serverUri.of(options.serverUri),
|
|
284
|
+
workspaceFolders.of(options.workspaceFolders),
|
|
275
285
|
rootUri.of(options.rootUri),
|
|
276
286
|
documentUri.of(options.documentUri),
|
|
277
287
|
languageId.of(options.languageId),
|
package/package.json
CHANGED
|
@@ -1,10 +0,0 @@
|
|
|
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 };
|