codemirror-languageserver 1.4.4 → 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 +1,10 @@
1
1
  {
2
2
  "name": "codemirror-languageserver",
3
- "version": "1.4.4",
3
+ "version": "1.6.0",
4
4
  "description": "Language Server Plugin for CodeMirror 6",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
7
- "prepare": "rollup --config"
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.18.6",
34
- "@codemirror/lint": "^0.18.3",
35
- "@codemirror/state": "^0.18.7",
36
- "@codemirror/tooltip": "^0.18.4",
37
- "@codemirror/view": "^0.18.15",
38
- "@open-rpc/client-js": "^1.6.2",
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": {