-
Notifications
You must be signed in to change notification settings - Fork 29.5k
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
Language server not working with notebook cells #105391
Comments
@renkun-ken please ask me anything about this ;-) We have this (preview) guide/intro: https://github.com/microsoft/notebook-extension-samples/blob/master/notebook-language-guide/notebook-language-guide.md. Our findings are that this needs involvement from language service authors but we are happy to help! |
@jrieken Thanks! I made some changes to vscode-r-lsp and the language server now works nicely with notebook code cells! But |
Looking very promising... So, you create a new service per notebook-file since a notebook roughly corresponds to a project, right?
Hm, that shouldn't happen and I cannot reproduce locally. Are you latest insiders and latest |
Yes, the R language service uses a multi-server approach to handle untitled documents, out-of-workspace files, and multi-root workspace. A notebook behaves like a project with multiple documents which share the same language server workspace.
Yes, I'm using the latest |
Can you point me to some code or let me try this? I have done some refactorings in that area but |
REditorSupport/vscode-R#394 is the R notebook implementation under development. At https://github.com/Ikuyadeu/vscode-R/pull/394/files#diff-896fa9128d2e83307ffcf26741d257d2R66-R70, I got I could not get the text of the cell and nor could I set the output of the cell. It's very likely that I have messed up something here. It would be nice if you could clone the project and see if you could reproduce it. |
@renkun-ken we have changed how kernels are registered. That might be the problem here. Instead of having it exposed as |
I tried the following but still no luck. I'm not sure how I could fill in the public label = 'R Kernel';
// public kernel = this;
private kernelScript: string;
private disposables: vscode.Disposable[] = [];
private readonly notebooks = new Map<string, RNotebook>();
private runIndex: number = 0;
constructor(kernelScript: string) {
this.kernelScript = kernelScript;
this.disposables.push(
vscode.notebook.registerNotebookKernelProvider({
viewType: 'r'
}, {
provideKernels: () => {
return [this];
}
}),
vscode.notebook.onDidOpenNotebookDocument(document => {
const docKey = document.uri.toString();
if (!this.notebooks.has(docKey)) {
const notebook = new RNotebook(this.kernelScript, document);
notebook.restartKernel();
this.notebooks.set(docKey, notebook);
}
}),
vscode.notebook.onDidCloseNotebookDocument(document => {
const docKey = document.uri.toString();
const notebook = this.notebooks.get(docKey);
if (notebook) {
notebook.dispose();
this.notebooks.delete(docKey);
}
}),
);
} |
Try |
|
Closing now. Thanks for your timely answers! I'll file new issue if needed. May I type @jrieken in the issues of vscode-R or vscode-r-lsp extensions repo regarding notebook questions? It's so efficient to get problem solved. |
Yes, please do so! We are super keen on seeing what others do with native notebooks and we are very interested in feedback and issues that early adopters are facing. So, please let the feedback come, be it API or UX. I will also subscribe you to #93265 on which we announce new and changed APIs. |
Thanks! |
Related: REditorSupport/vscode-R#396.
Steps to Reproduce:
*.Rmd
file as a notebook.I have not seen any documentation (e.g. https://code.visualstudio.com/api/extension-guides/notebook) or example (e.g. https://github.com/microsoft/vscode-nodebook) yet talking about how existing language server/clients should be modified to work with notebook cells. It looks like Pylance is made to support notebook but it is not open source.
Does this issue occur when all extensions are disabled?: Yes
The text was updated successfully, but these errors were encountered: