codemirror-languageserver 1.21.0 → 1.22.1

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 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
 
@@ -167,7 +167,7 @@ import { formatDocument, formatSelection } from 'codemirror-languageserver';
167
167
 
168
168
  const formattingKeymap = keymap.of([
169
169
  { key: 'Shift-Alt-f', run: formatDocument },
170
- { key: 'Ctrl-k Ctrl-f', run: formatSelection },
170
+ { key: 'Shift-Alt-g', run: formatSelection },
171
171
  ]);
172
172
  ```
173
173
 
package/dist/index.d.ts CHANGED
@@ -1,12 +1,12 @@
1
- export { LanguageServerClient, languageServerPlugin, SynchronizationMethod, } from './plugin';
2
- export { WebSocketTransport } from './jsonrpc';
3
- export type { Transport } from './jsonrpc';
4
- export { jumpToDefinition, jumpToDefinitionPos, jumpToDefinitionKeymap, } from './definition';
5
- export { formatDocument, formatSelection, formattingOptions, } from './formatting';
6
- export { renameSymbol } from './rename';
7
- export { PyrightInitializationOptions, RustAnalyzerInitializationOptions, TypeScriptInitializationOptions, ESLintInitializationOptions, ClangdInitializationOptions, GoplsInitializationOptions, } from './initialization';
8
- import { LanguageServerClient, SynchronizationMethod } from './plugin';
9
- import type { LanguageServerClientOptions, LanguageServerBaseOptions } from './plugin';
1
+ export { LanguageServerClient, languageServerPlugin, SynchronizationMethod, } from './plugin.js';
2
+ export { WebSocketTransport } from './jsonrpc.js';
3
+ export type { Transport } from './jsonrpc.js';
4
+ export { jumpToDefinition, jumpToDefinitionPos, jumpToDefinitionKeymap, } from './definition.js';
5
+ export { formatDocument, formatSelection, formattingOptions, } from './formatting.js';
6
+ export { renameSymbol } from './rename.js';
7
+ export { PyrightInitializationOptions, RustAnalyzerInitializationOptions, TypeScriptInitializationOptions, ESLintInitializationOptions, ClangdInitializationOptions, GoplsInitializationOptions, } from './initialization.js';
8
+ import { LanguageServerClient, SynchronizationMethod } from './plugin.js';
9
+ import type { LanguageServerClientOptions, LanguageServerBaseOptions } from './plugin.js';
10
10
  interface LanguageServerOptions<InitializationOptions = unknown> extends LanguageServerClientOptions<InitializationOptions> {
11
11
  client?: LanguageServerClient<InitializationOptions>;
12
12
  allowHTMLContent?: boolean;
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.pendingChanges = [
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
- if (!this.pendingChanges) {
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
@@ -1,5 +1,5 @@
1
1
  import { EditorView, Tooltip, ViewPlugin } from '@codemirror/view';
2
- import type { Transport } from './jsonrpc';
2
+ import type { Transport } from './jsonrpc.js';
3
3
  import { CompletionTriggerKind } from 'vscode-languageserver-protocol';
4
4
  import type { CompletionContext, CompletionResult } from '@codemirror/autocomplete';
5
5
  import type { PluginValue, ViewUpdate } from '@codemirror/view';
@@ -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;