Skip to content

Commit 2dc4089

Browse files
committed
Move to exclusion list for config.
Take reviews into accounts
1 parent c7afdc4 commit 2dc4089

File tree

3 files changed

+21
-19
lines changed

3 files changed

+21
-19
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ from the Language Server (in notebook).
6666
If the kernel is too slow to respond promptly only the Language Server suggestions will be shown (default threshold: 0.6s).
6767
You can configure the completer to not attempt to fetch the kernel completions if the kernel is busy (skipping the 0.6s timeout).
6868

69-
You can deactivate the kernel suggestions by setting the `useKernelCompletions` to `false` in the `completion` section
70-
of advanced settings. Alternatively if you _only_ want kernel completions you can set `useLspCompletions` to `false`.
71-
Or both if you like to code in hardcore mode and get no completions.
69+
You can deactivate the kernel suggestions by adding `"kenel"` to the `disableCompletionsFrom` in the `completion` section
70+
of _Advanced Settings_. Alternatively if you _only_ want kernel completions you can add `"languageServer"` to the same
71+
setting; Or add both if you like to code in hardcore mode and get no completions, or if another provider has been added.
7272

7373
### Rename
7474

packages/jupyterlab-lsp/schema/completion.json

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,11 @@
4141
"type": "number",
4242
"description": "The time to wait for the kernel completions suggestions in milliseconds. Set to 0 to disable kernel completions, or to -1 to wait indefinitely (not recommended)."
4343
},
44-
"useKernelCompletions": {
45-
"title": "Request Kernel Completion",
46-
"type": "boolean",
47-
"default": true,
48-
"description": "Whether to send completions request to the kernel."
49-
},
50-
"useLspCompletions": {
51-
"title": "Request LSP Completion",
52-
"type": "boolean",
53-
"default": true,
54-
"description": "Whether to send completions request to the lsp server."
44+
"disableCompletionsFrom": {
45+
"description": "The sources from which to exclude completion from. Possible values include 'kernel', 'languageServer'.",
46+
"type": "array",
47+
"default": [],
48+
"uniqueItems": true
5549
},
5650
"waitForBusyKernel": {
5751
"title": "Wait for kernel if busy",

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

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,19 @@ export class LSPConnector
7979
}
8080

8181
protected get use_lsp_completions(): boolean {
82-
return this.options.settings.composite.useLspCompletions;
82+
return (
83+
this.options.settings.composite.disableCompletionsFrom.indexOf(
84+
'languageServer'
85+
) == -1
86+
);
8387
}
8488

8589
protected get use_kernel_completions(): boolean {
86-
return this.options.settings.composite.useKernelCompletions;
90+
return (
91+
this.options.settings.composite.disableCompletionsFrom.indexOf(
92+
'kernel'
93+
) == -1
94+
);
8795
}
8896

8997
protected get suppress_continuous_hinting_in(): string[] {
@@ -220,7 +228,6 @@ export class LSPConnector
220228
let virtual_cursor = virtual_editor.root_position_to_virtual_position(
221229
cursor_in_root
222230
);
223-
224231
const lsp_promise: Promise<CompletionHandler.ICompletionItemsReply> = this
225232
.use_lsp_completions
226233
? this.fetch_lsp(
@@ -240,6 +247,7 @@ export class LSPConnector
240247
const kernelTimeout = this._kernel_timeout;
241248

242249
if (
250+
this.use_kernel_completions &&
243251
this._kernel_connector &&
244252
this._has_kernel &&
245253
(this._is_kernel_idle || this._should_wait_for_busy_kernel) &&
@@ -285,10 +293,10 @@ export class LSPConnector
285293
lsp_promise.catch(p => p)
286294
]).then(([kernel, lsp]) => {
287295
let replies = [];
288-
if (this.use_kernel_completions) {
296+
if (kernel != null) {
289297
replies.push(this.transform_reply(kernel));
290298
}
291-
if (this.use_lsp_completions) {
299+
if (lsp != null) {
292300
replies.push(lsp);
293301
}
294302
return this.merge_replies(replies, this._editor);

0 commit comments

Comments
 (0)