-
Notifications
You must be signed in to change notification settings - Fork 148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow to disable LSP or Kernel completions independently. #586
Conversation
Some use love LSP for many of its features, but prefer to keep completions via the kernel. This adds two boolean flags in the configuration to not send completions request to LSP and not send completions requests to the kernel. See jupyter-lsp#440
README.md
Outdated
@@ -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. |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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).
packages/jupyterlab-lsp/src/features/completion/completion_handler.ts
Outdated
Show resolved
Hide resolved
"title": "Request LSP Completion", | ||
"type": "boolean", | ||
"default": true, | ||
"description": "Whether to send completions request to the lsp server." |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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.
Re: notebook. Gah. Yeah. Been thinking about this for a long time. Having implemented this in a number of places, I'd love it if per-notebook settings just worked across every plugin in a Alternately, we've talked about having per-(glob|fnmatch|regex) (probably the latter) settings which could be configured per-plugin. At any rate, I don't think we tackle that on this PR, but should probably hoist it (at least) to an issue on this repo, if not to core. |
Commented here: jupyterlab/jupyterlab#8148 (comment) |
Woo green! |
Thank you @Carreau. I wonder if having this as a single setting with an array of completion sources to disable (e.g. |
That was my initial thought as well, either an include and exclude list. as I pointed above that would be fine with me; though it might be a bit harder to provide actions to enable disable, I mean that's only a couple of lines of code so I can switch to that. |
Take reviews into accounts
Updated to take comments into accounts. |
Thank you. The one final thing I would like your feedback on is naming of the options. I already introduced a concept of "CompletionSource" to make it easy to add new sources and to display the name of the source in the interface to make user aware why they do not see e.g. documentation for a specific completion item. These are currently named "Kernel" and "LSP": Should we align the source "name" that is displayed with the identifier in settings? I am not saying that they need to be identical. Just curious if you have thoughts whether using "languageServer" (identifier) + "Language Server" (name in UI) is actually better than using "lsp" (idnetifier) and "LSP" (name in the UI). Both would work for me. |
I'm 👍 to Further, if the jiggery-pokery around the |
I've change the options "LSP" and "Kernel" for the options values; I like "LSP", it's short and hard to misspell – which is good especially if you have to type it in the settings. I don't have particular preferences otherwise. @bollwyvl I agree with the refactor, but would prefer to do it separately, as I'm not yet that comfortable with typescript. I was thinking that a dict of names/promises or |
a681541
to
26fb463
Compare
LGTM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Some user love LSP for many of its features, but prefer to keep
completions via the kernel.
This adds two boolean flags in the configuration to not send completions
request to LSP and not send completions requests to the kernel.
References
#440 - I'm not sure how to toggle it on a per-notebook basis; I can likely add local state to LSPConnector which I guess is persisted on a per notebook basis but would welcome guidance on the best place to store that.
Code changes
User-facing changes
None by default. User may disable one or two completer sources.
Backwards-incompatible changes
None
Chores
Note: I haven't touched typescript and frontend in years, so I'm likely doing some things wrong;