Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## Changelog

### (unreleased)

- Add ability to deactivate Kernel completions or LSP completion through the settings.

### `jupyter-lsp 1.2.0` (2021-04-26)

- features:
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ 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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@krassowski would have to weigh in on this: if both of ours are turned off, is there some other place they might come from?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If am not mistaken we are taking an absolute control of completer and nothing else can provide completions just yet, but this will change very soon allowing Kite and Snippets to provide custom completion items to our endpoint (and afterwards we will move it to JupyterLab for 4.0).

By very soon I mean not earlier than end of May (sadly won't have time to on it earlier).


### Rename

Rename variables, functions and more, in both: notebooks and the file editor.
Expand Down
12 changes: 12 additions & 0 deletions packages/jupyterlab-lsp/schema/completion.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@
"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."
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we have LSP in the top-level description, and the name of the project, sure, but perhaps useLangugeServerCompletions. And certainly to the language server

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, as i expand this big-ol-file to look below... we already have kernelCompletionsFirst. I wonder if these could be condensed into something like the below, and put a 4.0 deprecation warning on KCF:

completionSources:
  description: The sources from which to fetch completions. Order determines tiebreakers. An empty list will disable completions provided by this plugin.
  type: array
  default: [languageServer, kernel]
  uniqueItems: true
  items:
    enum: [languageServer, kernel]

Thoughts @krassowski

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The completionSources would work for me to but I would want to avoid enum to allow for completions from other sources too. In the end the plan is that it will be all removed when JupyterLab 4.0 is released and takes care of that for us (this is when we PR a multi-source completion mechanism which will prevent extension clashes).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with anything you like.
I also thought that bool could at some point in the future allow to generate checkboxes, and easier to toggle via an action, but up to you.

},
"waitForBusyKernel": {
"title": "Wait for kernel if busy",
"default": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ export class LSPConnector
return this.options.settings.composite.kernelCompletionsFirst;
}

protected get use_lsp_completions(): boolean {
return this.options.settings.composite.useLspCompletions;
}

protected get use_kernel_completions(): boolean {
return this.options.settings.composite.useKernelCompletions;
}

protected get suppress_continuous_hinting_in(): string[] {
return this.options.settings.composite.suppressContinuousHintingIn;
}
Expand Down Expand Up @@ -213,15 +221,19 @@ export class LSPConnector
cursor_in_root
);

const lsp_promise = this.fetch_lsp(
token,
typed_character,
virtual_start,
virtual_end,
virtual_cursor,
document,
position_in_token
);
const lsp_promise: Promise<CompletionHandler.ICompletionItemsReply> = this
.use_lsp_completions
? this.fetch_lsp(
token,
typed_character,
virtual_start,
virtual_end,
virtual_cursor,
document,
position_in_token
)
: Promise.resolve(null);

let promise: Promise<CompletionHandler.ICompletionItemsReply> = null;

try {
Expand Down Expand Up @@ -271,12 +283,16 @@ export class LSPConnector
promise = Promise.all([
kernel_promise.catch(p => p),
lsp_promise.catch(p => p)
]).then(([kernel, lsp]) =>
this.merge_replies(
[this.transform_reply(kernel), lsp],
this._editor
)
);
]).then(([kernel, lsp]) => {
let replies = [];
if (this.use_kernel_completions) {
replies.push(this.transform_reply(kernel));
}
if (this.use_lsp_completions) {
replies.push(lsp);
}
return this.merge_replies(replies, this._editor);
});
}
}
if (!promise) {
Expand Down