Skip to content

Commit

Permalink
Move to exclusion list for config.
Browse files Browse the repository at this point in the history
Take reviews into accounts
  • Loading branch information
Carreau committed Apr 27, 2021
1 parent c7afdc4 commit 2dc4089
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 19 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ from the Language Server (in notebook).
If the kernel is too slow to respond promptly only the Language Server suggestions will be shown (default threshold: 0.6s).
You can configure the completer to not attempt to fetch the kernel completions if the kernel is busy (skipping the 0.6s timeout).

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

### Rename

Expand Down
16 changes: 5 additions & 11 deletions packages/jupyterlab-lsp/schema/completion.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,11 @@
"type": "number",
"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)."
},
"useKernelCompletions": {
"title": "Request Kernel Completion",
"type": "boolean",
"default": true,
"description": "Whether to send completions request to the kernel."
},
"useLspCompletions": {
"title": "Request LSP Completion",
"type": "boolean",
"default": true,
"description": "Whether to send completions request to the lsp server."
"disableCompletionsFrom": {
"description": "The sources from which to exclude completion from. Possible values include 'kernel', 'languageServer'.",
"type": "array",
"default": [],
"uniqueItems": true
},
"waitForBusyKernel": {
"title": "Wait for kernel if busy",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,19 @@ export class LSPConnector
}

protected get use_lsp_completions(): boolean {
return this.options.settings.composite.useLspCompletions;
return (
this.options.settings.composite.disableCompletionsFrom.indexOf(
'languageServer'
) == -1
);
}

protected get use_kernel_completions(): boolean {
return this.options.settings.composite.useKernelCompletions;
return (
this.options.settings.composite.disableCompletionsFrom.indexOf(
'kernel'
) == -1
);
}

protected get suppress_continuous_hinting_in(): string[] {
Expand Down Expand Up @@ -220,7 +228,6 @@ export class LSPConnector
let virtual_cursor = virtual_editor.root_position_to_virtual_position(
cursor_in_root
);

const lsp_promise: Promise<CompletionHandler.ICompletionItemsReply> = this
.use_lsp_completions
? this.fetch_lsp(
Expand All @@ -240,6 +247,7 @@ export class LSPConnector
const kernelTimeout = this._kernel_timeout;

if (
this.use_kernel_completions &&
this._kernel_connector &&
this._has_kernel &&
(this._is_kernel_idle || this._should_wait_for_busy_kernel) &&
Expand Down Expand Up @@ -285,10 +293,10 @@ export class LSPConnector
lsp_promise.catch(p => p)
]).then(([kernel, lsp]) => {
let replies = [];
if (this.use_kernel_completions) {
if (kernel != null) {
replies.push(this.transform_reply(kernel));
}
if (this.use_lsp_completions) {
if (lsp != null) {
replies.push(lsp);
}
return this.merge_replies(replies, this._editor);
Expand Down

0 comments on commit 2dc4089

Please sign in to comment.