Skip to content

Commit 913bfd0

Browse files
committed
Display 'source' or 'detail' next to completion label
1 parent aee8809 commit 913bfd0

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

packages/jupyterlab-lsp/schema/completion.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,13 @@
7070
"type": "boolean",
7171
"description": "Should perfect matches be included in the completion suggestions list?"
7272
},
73+
"labelExtra": {
74+
"title": "Text to display next to completion label",
75+
"default": "auto",
76+
"type": "string",
77+
"enum": ["detail", "type", "source", "auto"],
78+
"description": "What to display next to the completion label, one of: 'detail', 'type', 'source', 'auto'. The default 'auto' will display whichever information is available."
79+
},
7380
"typesMap": {
7481
"title": "Mapping of custom kernel types to valid completion kind names",
7582
"description": "Mapping used for icon selection. The kernel types (keys) are case-insensitive. Accepted values are the names of CompletionItemKind and 'Kernel' literal. The defaults aim to provide good initial experience for Julia, Python and R kernels.",

packages/jupyterlab-lsp/src/features/completion/renderer.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,19 @@ export class LSPCompletionRenderer
1818
this.activeChanged = new Signal(this);
1919
}
2020

21+
protected getExtraInfo(item: LazyCompletionItem): string {
22+
switch (this.options.integrator.settings.composite.labelExtra) {
23+
case 'detail':
24+
return item.detail;
25+
case 'type':
26+
return item.type;
27+
case 'source':
28+
return item.source.name;
29+
case 'auto':
30+
return [item.detail, item.type, item.source.name].filter(x => !!x)[0];
31+
}
32+
}
33+
2134
createCompletionItemNode(
2235
item: LazyCompletionItem,
2336
orderedTypes: string[]
@@ -46,6 +59,10 @@ export class LSPCompletionRenderer
4659
});
4760
}
4861

62+
const extraText = this.getExtraInfo(item);
63+
const extraElement = li.querySelector('.jp-Completer-typeExtended');
64+
extraElement.textContent = extraText;
65+
4966
return li;
5067
}
5168

0 commit comments

Comments
 (0)