Skip to content

Commit a121504

Browse files
authored
Merge pull request jupyter-lsp#698 from jupyter-lsp/details-below-layout
Implement details-below completer layout
2 parents 6b1b784 + fc62298 commit a121504

File tree

3 files changed

+88
-4
lines changed

3 files changed

+88
-4
lines changed

packages/completion-theme/style/index.css

Lines changed: 77 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,21 @@
2424
overflow: auto;
2525
}
2626

27+
.jp-Completer {
28+
--lsp-completer-max-label-width: 300px;
29+
--lsp-completer-max-detail-width: 200px;
30+
}
31+
2732
.jp-Completer-match {
28-
max-width: 400px;
33+
max-width: var(--lsp-completer-max-label-width);
2934
overflow-x: hidden;
3035
white-space: nowrap;
3136
display: block;
3237
text-overflow: ellipsis;
3338
}
3439

3540
.jp-mod-active .jp-Completer-match {
36-
max-width: 600px;
37-
white-space: break-spaces;
38-
height: auto;
41+
text-overflow: clip;
3942
}
4043

4144
.lsp-completer-placeholder:after {
@@ -47,3 +50,73 @@
4750
.jp-Completer-docpanel pre code {
4851
font-size: 90%;
4952
}
53+
54+
body[data-lsp-completer-layout='detail-below'] .jp-Completer-item {
55+
--lsp-completer-label-height: 24px;
56+
--lsp-completer-detail-height: 20px;
57+
--lsp-completer-icon-width: 16px;
58+
height: var(--lsp-completer-label-height);
59+
display: grid;
60+
grid-template-areas:
61+
'icon label'
62+
'detail detail';
63+
grid-template-columns: min-content 1fr;
64+
}
65+
66+
body[data-lsp-completer-layout='detail-below']
67+
.jp-Completer-item.jp-mod-active {
68+
height: calc(
69+
var(--lsp-completer-detail-height) + var(--lsp-completer-label-height)
70+
);
71+
}
72+
73+
body[data-lsp-completer-layout='detail-below'] .jp-Completer-icon {
74+
grid-area: icon;
75+
width: var(--lsp-completer-icon-width);
76+
}
77+
78+
body[data-lsp-completer-layout='detail-below'] .jp-Completer-match {
79+
grid-area: label;
80+
overflow: hidden;
81+
height: var(--lsp-completer-label-height);
82+
}
83+
84+
.jp-Completer-item .jp-Completer-typeExtended {
85+
max-width: var(--lsp-completer-max-detail-width);
86+
min-height: 50px;
87+
overflow-x: hidden;
88+
text-overflow: ellipsis;
89+
white-space: nowrap;
90+
}
91+
92+
.jp-mod-active .jp-Completer-typeExtended {
93+
text-overflow: clip;
94+
}
95+
96+
body[data-lsp-completer-layout='detail-below'] .jp-Completer-typeExtended {
97+
grid-area: detail;
98+
text-align: left;
99+
padding-left: calc(var(--lsp-completer-icon-width) + 8px);
100+
height: var(--lsp-completer-detail-height);
101+
line-height: var(--lsp-completer-detail-height);
102+
display: none;
103+
position: relative;
104+
top: -2px;
105+
overflow: hidden;
106+
max-width: calc(
107+
var(--lsp-completer-max-label-width) + var(--lsp-completer-max-detail-width)
108+
);
109+
}
110+
111+
body[data-lsp-completer-layout='detail-below'] .jp-Completer-match {
112+
overflow: hidden;
113+
max-width: calc(
114+
var(--lsp-completer-max-label-width) + var(--lsp-completer-max-detail-width)
115+
);
116+
}
117+
118+
body[data-lsp-completer-layout='detail-below']
119+
.jp-Completer-item.jp-mod-active
120+
.jp-Completer-typeExtended {
121+
display: block;
122+
}

packages/jupyterlab-lsp/schema/completion.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,13 @@
8383
"enum": ["detail", "type", "source", "auto"],
8484
"description": "What to display next to the completion label, one of: 'detail', 'type', 'source', 'auto'. The default 'auto' will display whichever information is available."
8585
},
86+
"layout": {
87+
"title": "Completer layout",
88+
"default": "side-by-side",
89+
"type": "string",
90+
"enum": ["detail-below", "side-by-side"],
91+
"description": "Layout of the completer, one of: 'detail-below', 'side-by-side'"
92+
},
8693
"typesMap": {
8794
"title": "Mapping of custom kernel types to valid completion kind names",
8895
"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/completion.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ export class CompletionLabIntegration implements IFeatureLabIntegration {
121121
completionThemeManager.set_icons_overrides(
122122
this.settings.composite.typesMap
123123
);
124+
if (!settings.composite.disable) {
125+
document.body.dataset.lspCompleterLayout =
126+
this.settings.composite.layout;
127+
}
124128
if (this.current_completion_handler) {
125129
this.model.settings.caseSensitive =
126130
this.settings.composite.caseSensitive;

0 commit comments

Comments
 (0)