codemirror-languageserver 1.21.0 → 1.22.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 +1 -1
- package/dist/index.js +3 -26
- package/dist/plugin.d.ts +0 -2
- package/{demo/dist/demo.js → docs/dist/gh-pages.js} +4670 -3427
- package/docs/dist/lsp-worker.js +653 -0
- package/docs/gh-pages.js +115 -0
- package/docs/index.html +459 -0
- package/docs/lsp-worker.js +635 -0
- package/docs/worker-transport.js +50 -0
- package/package.json +5 -5
- package/rollup.config.gh-pages.js +34 -0
- package/demo/demo.js +0 -109
- package/demo/index.html +0 -17
- package/rollup.config.demo.js +0 -30
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
This plugin connects a [CodeMirror 6](https://codemirror.net/) editor with a [Language Server](https://microsoft.github.io/language-server-protocol/) over WebSocket, providing IDE-like features in the browser.
|
|
6
6
|
|
|
7
|
-
[How It Works](https://hjr265.me/blog/codemirror-lsp/)
|
|
7
|
+
[How It Works](https://hjr265.me/blog/codemirror-lsp/) | [Live Demo](https://furqansoftware.github.io/codemirror-languageserver/)
|
|
8
8
|
|
|
9
9
|
## Features
|
|
10
10
|
|
package/dist/index.js
CHANGED
|
@@ -179,7 +179,6 @@ function changeSetToEvents(doc, changes) {
|
|
|
179
179
|
}
|
|
180
180
|
|
|
181
181
|
const timeout = 10000;
|
|
182
|
-
const changesDelay = 500;
|
|
183
182
|
const CompletionItemKindMap = Object.fromEntries(Object.entries(CompletionItemKind).map(([key, value]) => [value, key]));
|
|
184
183
|
const useLast = (values) => values.reduce((_, v) => v, '');
|
|
185
184
|
Facet.define({
|
|
@@ -393,8 +392,6 @@ var SynchronizationMethod;
|
|
|
393
392
|
class LanguageServerPlugin {
|
|
394
393
|
constructor(view, { client, documentUri, languageId, allowHTMLContent, synchronizationMethod, }) {
|
|
395
394
|
this.view = view;
|
|
396
|
-
this.changesTimeout = null;
|
|
397
|
-
this.pendingChanges = null;
|
|
398
395
|
this.client = client;
|
|
399
396
|
this.documentUri = documentUri;
|
|
400
397
|
this.languageId = languageId;
|
|
@@ -411,40 +408,20 @@ class LanguageServerPlugin {
|
|
|
411
408
|
if (!docChanged) {
|
|
412
409
|
return;
|
|
413
410
|
}
|
|
414
|
-
if (this.changesTimeout) {
|
|
415
|
-
clearTimeout(this.changesTimeout);
|
|
416
|
-
}
|
|
417
411
|
switch (this.synchronizationMethod) {
|
|
418
412
|
case SynchronizationMethod.Full:
|
|
419
|
-
this.
|
|
413
|
+
this.sendChanges([
|
|
420
414
|
{
|
|
421
415
|
text: this.view.state.doc.toString(),
|
|
422
416
|
},
|
|
423
|
-
];
|
|
417
|
+
]);
|
|
424
418
|
break;
|
|
425
419
|
case SynchronizationMethod.Incremental:
|
|
426
|
-
|
|
427
|
-
this.pendingChanges = [];
|
|
428
|
-
}
|
|
429
|
-
this.pendingChanges.push(...changeSetToEvents(startState.doc, changes));
|
|
420
|
+
this.sendChanges(changeSetToEvents(startState.doc, changes));
|
|
430
421
|
break;
|
|
431
422
|
}
|
|
432
|
-
this.changesTimeout = setTimeout(() => {
|
|
433
|
-
this.changesTimeout = null;
|
|
434
|
-
if (this.pendingChanges) {
|
|
435
|
-
this.sendChanges(this.pendingChanges);
|
|
436
|
-
this.pendingChanges = null;
|
|
437
|
-
}
|
|
438
|
-
}, changesDelay);
|
|
439
423
|
}
|
|
440
424
|
destroy() {
|
|
441
|
-
if (this.changesTimeout) {
|
|
442
|
-
clearTimeout(this.changesTimeout);
|
|
443
|
-
if (this.pendingChanges) {
|
|
444
|
-
this.sendChanges(this.pendingChanges);
|
|
445
|
-
this.pendingChanges = null;
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
425
|
this.client.detachPlugin(this);
|
|
449
426
|
}
|
|
450
427
|
async initialize({ documentText }) {
|
package/dist/plugin.d.ts
CHANGED
|
@@ -127,8 +127,6 @@ export declare class LanguageServerPlugin implements PluginValue {
|
|
|
127
127
|
private documentVersion;
|
|
128
128
|
private allowHTMLContent;
|
|
129
129
|
private synchronizationMethod;
|
|
130
|
-
private changesTimeout;
|
|
131
|
-
private pendingChanges;
|
|
132
130
|
constructor(view: EditorView, { client, documentUri, languageId, allowHTMLContent, synchronizationMethod, }: {
|
|
133
131
|
client: LanguageServerClient;
|
|
134
132
|
documentUri: string;
|