codemirror-languageserver 1.16.0 → 1.17.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.js CHANGED
@@ -87,6 +87,9 @@ class LanguageServerClient {
87
87
  documentationFormat: ['markdown', 'plaintext'],
88
88
  deprecatedSupport: false,
89
89
  preselectSupport: false,
90
+ resolveSupport: {
91
+ properties: ['detail', 'documentation'],
92
+ },
90
93
  },
91
94
  contextSupport: true,
92
95
  },
@@ -155,6 +158,9 @@ class LanguageServerClient {
155
158
  async textDocumentTypeDefinition(params) {
156
159
  return await this.request('textDocument/typeDefinition', params, timeout);
157
160
  }
161
+ async completionItemResolve(params) {
162
+ return await this.request('completionItem/resolve', params, timeout);
163
+ }
158
164
  attachPlugin(plugin) {
159
165
  this.plugins.push(plugin);
160
166
  }
@@ -328,7 +334,8 @@ class LanguageServerPlugin {
328
334
  });
329
335
  }
330
336
  }
331
- const options = items.map(({ detail, label, kind, textEdit, documentation, additionalTextEdits, }) => {
337
+ const options = items.map((item) => {
338
+ const { detail, label, kind, textEdit, documentation, additionalTextEdits, } = item;
332
339
  const completion = {
333
340
  label,
334
341
  detail,
@@ -366,20 +373,26 @@ class LanguageServerPlugin {
366
373
  },
367
374
  type: kind && CompletionItemKindMap[kind].toLowerCase(),
368
375
  };
369
- if (documentation) {
370
- completion.info = async () => {
371
- const dom = document.createElement('div');
372
- dom.classList.add('documentation');
373
- if (this.allowHTMLContent) {
374
- dom.innerHTML = await formatContents(documentation);
375
- }
376
- else {
377
- dom.textContent =
378
- await formatContents(documentation);
379
- }
380
- return dom;
381
- };
382
- }
376
+ completion.info = async () => {
377
+ var _a;
378
+ let { documentation } = item;
379
+ if (!documentation &&
380
+ ((_a = this.client.capabilities.completionProvider) === null || _a === void 0 ? void 0 : _a.resolveProvider)) {
381
+ const resolvedItem = await this.client.completionItemResolve(item);
382
+ documentation = resolvedItem.documentation;
383
+ }
384
+ if (!documentation)
385
+ return null;
386
+ const dom = document.createElement('div');
387
+ dom.classList.add('documentation');
388
+ if (this.allowHTMLContent) {
389
+ dom.innerHTML = await formatContents(documentation);
390
+ }
391
+ else {
392
+ dom.textContent = await formatContents(documentation);
393
+ }
394
+ return dom;
395
+ };
383
396
  return completion;
384
397
  });
385
398
  return {
package/dist/plugin.d.ts CHANGED
@@ -24,6 +24,7 @@ interface LSPRequestMap {
24
24
  LSP.TypeDefinitionParams,
25
25
  LSP.Location | LSP.Location[] | LSP.LocationLink[] | null
26
26
  ];
27
+ 'completionItem/resolve': [LSP.CompletionItem, LSP.CompletionItem];
27
28
  }
28
29
  interface LSPNotifyMap {
29
30
  initialized: LSP.InitializedParams;
@@ -69,6 +70,7 @@ export declare class LanguageServerClient<InitializationOptions = unknown> {
69
70
  textDocumentDefinition(params: LSP.DefinitionParams): Promise<LSP.Location | LSP.Location[] | LSP.LocationLink[]>;
70
71
  textDocumentDeclaration(params: LSP.DeclarationParams): Promise<LSP.Location | LSP.Location[] | LSP.LocationLink[]>;
71
72
  textDocumentTypeDefinition(params: LSP.TypeDefinitionParams): Promise<LSP.Location | LSP.Location[] | LSP.LocationLink[]>;
73
+ completionItemResolve(params: LSP.CompletionItem): Promise<LSP.CompletionItem>;
72
74
  attachPlugin(plugin: LanguageServerPlugin): void;
73
75
  detachPlugin(plugin: LanguageServerPlugin): void;
74
76
  protected request<K extends keyof LSPRequestMap>(method: K, params: LSPRequestMap[K][0], timeout: number): Promise<LSPRequestMap[K][1]>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codemirror-languageserver",
3
- "version": "1.16.0",
3
+ "version": "1.17.0",
4
4
  "description": "Language Server Plugin for CodeMirror 6",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",