codemirror-languageserver 1.7.0 → 1.8.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 +12 -18
- package/package.json +5 -6
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 { ViewPlugin, hoverTooltip, EditorView } 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,16 @@ 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.connection.addEventListener('message', (message) => {
|
|
30
|
-
const data = JSON.parse(message.data);
|
|
31
|
-
if (data.method && data.id)
|
|
32
|
-
this.processRequest(data);
|
|
33
|
-
});
|
|
34
27
|
this.initialize();
|
|
35
28
|
}
|
|
36
29
|
async initialize() {
|
|
@@ -129,13 +122,6 @@ class LanguageServerClient {
|
|
|
129
122
|
notify(method, params) {
|
|
130
123
|
return this.client.notify({ method, params });
|
|
131
124
|
}
|
|
132
|
-
processRequest({ id }) {
|
|
133
|
-
this.transport.connection.send(JSON.stringify({
|
|
134
|
-
jsonrpc: '2.0',
|
|
135
|
-
id,
|
|
136
|
-
result: null
|
|
137
|
-
}));
|
|
138
|
-
}
|
|
139
125
|
processNotification(notification) {
|
|
140
126
|
for (const plugin of this.plugins)
|
|
141
127
|
plugin.processNotification(notification);
|
|
@@ -320,6 +306,14 @@ class LanguageServerPlugin {
|
|
|
320
306
|
}
|
|
321
307
|
}
|
|
322
308
|
function languageServer(options) {
|
|
309
|
+
const serverUri = options.serverUri;
|
|
310
|
+
delete options.serverUri;
|
|
311
|
+
return languageServerWithTransport({
|
|
312
|
+
...options,
|
|
313
|
+
transport: new WebSocketTransport(serverUri)
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
function languageServerWithTransport(options) {
|
|
323
317
|
let plugin = null;
|
|
324
318
|
return [
|
|
325
319
|
client.of(options.client || new LanguageServerClient({ ...options, autoClose: true })),
|
|
@@ -421,4 +415,4 @@ const baseTheme = EditorView.baseTheme({
|
|
|
421
415
|
},
|
|
422
416
|
});
|
|
423
417
|
|
|
424
|
-
export { LanguageServerClient, languageServer };
|
|
418
|
+
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.8.0",
|
|
4
4
|
"description": "Language Server Plugin for CodeMirror 6",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -30,11 +30,10 @@
|
|
|
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/
|
|
37
|
-
"@codemirror/view": "^0.19.43",
|
|
33
|
+
"@codemirror/autocomplete": "^0.20.0",
|
|
34
|
+
"@codemirror/lint": "^0.20.0",
|
|
35
|
+
"@codemirror/state": "^0.20.0",
|
|
36
|
+
"@codemirror/view": "^0.20.0",
|
|
38
37
|
"@open-rpc/client-js": "^1.7.1",
|
|
39
38
|
"vscode-languageserver-protocol": "^3.16.0"
|
|
40
39
|
},
|