codemirror-languageserver 1.7.0 → 1.9.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/README.md +5 -3
- package/dist/index.d.ts +14 -13
- package/dist/index.js +27 -18
- package/package.json +11 -12
package/README.md
CHANGED
|
@@ -15,14 +15,16 @@ npm i codemirror-languageserver
|
|
|
15
15
|
``` js
|
|
16
16
|
import { languageServer } from 'codemirror-languageserver';
|
|
17
17
|
|
|
18
|
+
const transport = new WebSocketTransport(serverUri)
|
|
19
|
+
|
|
18
20
|
var ls = languageServer({
|
|
19
|
-
// WebSocket server
|
|
20
|
-
serverUri
|
|
21
|
+
// WebSocket server uri and other client options.
|
|
22
|
+
serverUri,
|
|
21
23
|
rootUri: 'file:///',
|
|
22
24
|
|
|
23
25
|
// Alternatively, to share the same client across multiple instances of this plugin.
|
|
24
26
|
client: new LanguageServerClient({
|
|
25
|
-
serverUri
|
|
27
|
+
serverUri,
|
|
26
28
|
rootUri: 'file:///'
|
|
27
29
|
}),
|
|
28
30
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { EditorView, ViewUpdate, PluginValue } from '@codemirror/view';
|
|
1
|
+
import { EditorView, Tooltip, ViewUpdate, PluginValue } from '@codemirror/view';
|
|
2
2
|
import * as LSP from 'vscode-languageserver-protocol';
|
|
3
3
|
import { CompletionTriggerKind, PublishDiagnosticsParams } from "vscode-languageserver-protocol";
|
|
4
4
|
import { CompletionContext, CompletionResult } from '@codemirror/autocomplete';
|
|
5
|
-
import {
|
|
5
|
+
import { Transport } from '@open-rpc/client-js/build/transports/Transport';
|
|
6
6
|
interface LSPEventMap {
|
|
7
7
|
'textDocument/publishDiagnostics': LSP.PublishDiagnosticsParams;
|
|
8
8
|
}
|
|
@@ -15,7 +15,6 @@ type Notification = {
|
|
|
15
15
|
};
|
|
16
16
|
}[keyof LSPEventMap];
|
|
17
17
|
declare class LanguageServerClient {
|
|
18
|
-
private serverUri;
|
|
19
18
|
private rootUri;
|
|
20
19
|
private workspaceFolders;
|
|
21
20
|
private autoClose?;
|
|
@@ -36,7 +35,6 @@ declare class LanguageServerClient {
|
|
|
36
35
|
detachPlugin(plugin: LanguageServerPlugin): void;
|
|
37
36
|
private request;
|
|
38
37
|
private notify;
|
|
39
|
-
private processRequest;
|
|
40
38
|
private processNotification;
|
|
41
39
|
}
|
|
42
40
|
declare class LanguageServerPlugin implements PluginValue {
|
|
@@ -70,19 +68,22 @@ declare class LanguageServerPlugin implements PluginValue {
|
|
|
70
68
|
processNotification(notification: Notification): void;
|
|
71
69
|
processDiagnostics(params: PublishDiagnosticsParams): void;
|
|
72
70
|
}
|
|
73
|
-
interface
|
|
74
|
-
serverUri: `ws://${string}` | `wss://${string}`;
|
|
71
|
+
interface LanguageServerBaseOptions {
|
|
75
72
|
rootUri: string | null;
|
|
76
73
|
workspaceFolders: LSP.WorkspaceFolder[] | null;
|
|
74
|
+
documentUri: string;
|
|
75
|
+
languageId: string;
|
|
76
|
+
}
|
|
77
|
+
interface LanguageServerClientOptions extends LanguageServerBaseOptions {
|
|
78
|
+
transport: Transport;
|
|
77
79
|
autoClose?: boolean;
|
|
78
80
|
}
|
|
79
|
-
interface LanguageServerOptions {
|
|
81
|
+
interface LanguageServerOptions extends LanguageServerClientOptions {
|
|
80
82
|
client?: LanguageServerClient;
|
|
83
|
+
}
|
|
84
|
+
interface LanguageServerWebsocketOptions extends LanguageServerBaseOptions {
|
|
81
85
|
serverUri: `ws://${string}` | `wss://${string}`;
|
|
82
|
-
rootUri: string | null;
|
|
83
|
-
workspaceFolders: LSP.WorkspaceFolder[] | null;
|
|
84
|
-
documentUri: string;
|
|
85
|
-
languageId: string;
|
|
86
86
|
}
|
|
87
|
-
declare function languageServer(options:
|
|
88
|
-
|
|
87
|
+
declare function languageServer(options: LanguageServerWebsocketOptions): import("@codemirror/state").Extension[];
|
|
88
|
+
declare function languageServerWithTransport(options: LanguageServerOptions): import("@codemirror/state").Extension[];
|
|
89
|
+
export { LanguageServerClient, languageServer, languageServerWithTransport };
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { autocompletion } from '@codemirror/autocomplete';
|
|
2
2
|
import { setDiagnostics } from '@codemirror/lint';
|
|
3
3
|
import { Facet } from '@codemirror/state';
|
|
4
|
-
import { hoverTooltip } from '@codemirror/
|
|
5
|
-
import {
|
|
6
|
-
import { WebSocketTransport, RequestManager, Client } from '@open-rpc/client-js';
|
|
4
|
+
import { EditorView, ViewPlugin, hoverTooltip } from '@codemirror/view';
|
|
5
|
+
import { RequestManager, Client, WebSocketTransport } from '@open-rpc/client-js';
|
|
7
6
|
import { CompletionItemKind, CompletionTriggerKind, DiagnosticSeverity } from 'vscode-languageserver-protocol';
|
|
8
7
|
|
|
9
8
|
const timeout = 10000;
|
|
@@ -15,22 +14,31 @@ const documentUri = Facet.define({ combine: useLast });
|
|
|
15
14
|
const languageId = Facet.define({ combine: useLast });
|
|
16
15
|
class LanguageServerClient {
|
|
17
16
|
constructor(options) {
|
|
18
|
-
this.serverUri = options.serverUri;
|
|
19
17
|
this.rootUri = options.rootUri;
|
|
20
18
|
this.workspaceFolders = options.workspaceFolders;
|
|
21
19
|
this.autoClose = options.autoClose;
|
|
22
20
|
this.plugins = [];
|
|
23
|
-
this.transport =
|
|
21
|
+
this.transport = options.transport;
|
|
24
22
|
this.requestManager = new RequestManager([this.transport]);
|
|
25
23
|
this.client = new Client(this.requestManager);
|
|
26
24
|
this.client.onNotification((data) => {
|
|
27
25
|
this.processNotification(data);
|
|
28
26
|
});
|
|
29
|
-
this.transport
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
27
|
+
const webSocketTransport = this.transport;
|
|
28
|
+
if (webSocketTransport && webSocketTransport.connection) {
|
|
29
|
+
// XXX(hjr265): Need a better way to do this. Relevant issue:
|
|
30
|
+
// https://github.com/FurqanSoftware/codemirror-languageserver/issues/9
|
|
31
|
+
webSocketTransport.connection.addEventListener('message', (message) => {
|
|
32
|
+
const data = JSON.parse(message.data);
|
|
33
|
+
if (data.method && data.id) {
|
|
34
|
+
webSocketTransport.connection.send(JSON.stringify({
|
|
35
|
+
jsonrpc: '2.0',
|
|
36
|
+
id: data.id,
|
|
37
|
+
result: null
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
34
42
|
this.initialize();
|
|
35
43
|
}
|
|
36
44
|
async initialize() {
|
|
@@ -129,13 +137,6 @@ class LanguageServerClient {
|
|
|
129
137
|
notify(method, params) {
|
|
130
138
|
return this.client.notify({ method, params });
|
|
131
139
|
}
|
|
132
|
-
processRequest({ id }) {
|
|
133
|
-
this.transport.connection.send(JSON.stringify({
|
|
134
|
-
jsonrpc: '2.0',
|
|
135
|
-
id,
|
|
136
|
-
result: null
|
|
137
|
-
}));
|
|
138
|
-
}
|
|
139
140
|
processNotification(notification) {
|
|
140
141
|
for (const plugin of this.plugins)
|
|
141
142
|
plugin.processNotification(notification);
|
|
@@ -320,6 +321,14 @@ class LanguageServerPlugin {
|
|
|
320
321
|
}
|
|
321
322
|
}
|
|
322
323
|
function languageServer(options) {
|
|
324
|
+
const serverUri = options.serverUri;
|
|
325
|
+
delete options.serverUri;
|
|
326
|
+
return languageServerWithTransport({
|
|
327
|
+
...options,
|
|
328
|
+
transport: new WebSocketTransport(serverUri)
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
function languageServerWithTransport(options) {
|
|
323
332
|
let plugin = null;
|
|
324
333
|
return [
|
|
325
334
|
client.of(options.client || new LanguageServerClient({ ...options, autoClose: true })),
|
|
@@ -421,4 +430,4 @@ const baseTheme = EditorView.baseTheme({
|
|
|
421
430
|
},
|
|
422
431
|
});
|
|
423
432
|
|
|
424
|
-
export { LanguageServerClient, languageServer };
|
|
433
|
+
export { LanguageServerClient, languageServer, languageServerWithTransport };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codemirror-languageserver",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0",
|
|
4
4
|
"description": "Language Server Plugin for CodeMirror 6",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -21,20 +21,19 @@
|
|
|
21
21
|
},
|
|
22
22
|
"license": "BSD-3-Clause",
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@babel/core": "^7.
|
|
25
|
-
"@babel/preset-env": "^7.
|
|
26
|
-
"@rollup/plugin-babel": "^5.3.
|
|
24
|
+
"@babel/core": "^7.18.6",
|
|
25
|
+
"@babel/preset-env": "^7.18.6",
|
|
26
|
+
"@rollup/plugin-babel": "^5.3.1",
|
|
27
27
|
"prettier": "^2.2.1",
|
|
28
|
-
"rollup": "^2.
|
|
29
|
-
"rollup-plugin-ts": "^
|
|
30
|
-
"typescript": "^4.
|
|
28
|
+
"rollup": "^2.75.7",
|
|
29
|
+
"rollup-plugin-ts": "^3.0.2",
|
|
30
|
+
"typescript": "^4.7.4"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@codemirror/autocomplete": "^0.
|
|
34
|
-
"@codemirror/lint": "^0.
|
|
35
|
-
"@codemirror/state": "^
|
|
36
|
-
"@codemirror/
|
|
37
|
-
"@codemirror/view": "^0.19.43",
|
|
33
|
+
"@codemirror/autocomplete": "^6.0.2",
|
|
34
|
+
"@codemirror/lint": "^6.0.0",
|
|
35
|
+
"@codemirror/state": "^6.1.0",
|
|
36
|
+
"@codemirror/view": "^6.0.2",
|
|
38
37
|
"@open-rpc/client-js": "^1.7.1",
|
|
39
38
|
"vscode-languageserver-protocol": "^3.16.0"
|
|
40
39
|
},
|