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/README.md +1 -1
- package/demo/dist/demo.js +36 -2018
- package/dist/index.js +28 -15
- package/dist/plugin.d.ts +2 -0
- package/package.json +1 -1
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((
|
|
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
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
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]>;
|