codemirror-languageserver 1.16.0 → 1.17.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 +1 -1
- package/demo/dist/demo.js +36 -2018
- package/dist/index.js +28 -16
- 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
|
}
|
|
@@ -247,7 +253,6 @@ class LanguageServerPlugin {
|
|
|
247
253
|
if (!this.client.ready || !this.client.capabilities.hoverProvider) {
|
|
248
254
|
return null;
|
|
249
255
|
}
|
|
250
|
-
this.sendChange({ documentText: view.state.doc.toString() });
|
|
251
256
|
const result = await this.client.textDocumentHover({
|
|
252
257
|
textDocument: { uri: this.documentUri },
|
|
253
258
|
position: { line, character },
|
|
@@ -328,7 +333,8 @@ class LanguageServerPlugin {
|
|
|
328
333
|
});
|
|
329
334
|
}
|
|
330
335
|
}
|
|
331
|
-
const options = items.map((
|
|
336
|
+
const options = items.map((item) => {
|
|
337
|
+
const { detail, label, kind, textEdit, documentation, additionalTextEdits, } = item;
|
|
332
338
|
const completion = {
|
|
333
339
|
label,
|
|
334
340
|
detail,
|
|
@@ -366,20 +372,26 @@ class LanguageServerPlugin {
|
|
|
366
372
|
},
|
|
367
373
|
type: kind && CompletionItemKindMap[kind].toLowerCase(),
|
|
368
374
|
};
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
375
|
+
completion.info = async () => {
|
|
376
|
+
var _a;
|
|
377
|
+
let { documentation } = item;
|
|
378
|
+
if (!documentation &&
|
|
379
|
+
((_a = this.client.capabilities.completionProvider) === null || _a === void 0 ? void 0 : _a.resolveProvider)) {
|
|
380
|
+
const resolvedItem = await this.client.completionItemResolve(item);
|
|
381
|
+
documentation = resolvedItem.documentation;
|
|
382
|
+
}
|
|
383
|
+
if (!documentation)
|
|
384
|
+
return null;
|
|
385
|
+
const dom = document.createElement('div');
|
|
386
|
+
dom.classList.add('documentation');
|
|
387
|
+
if (this.allowHTMLContent) {
|
|
388
|
+
dom.innerHTML = await formatContents(documentation);
|
|
389
|
+
}
|
|
390
|
+
else {
|
|
391
|
+
dom.textContent = await formatContents(documentation);
|
|
392
|
+
}
|
|
393
|
+
return dom;
|
|
394
|
+
};
|
|
383
395
|
return completion;
|
|
384
396
|
});
|
|
385
397
|
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]>;
|