-
Notifications
You must be signed in to change notification settings - Fork 327
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
NotebookCell
is missing outputs
field
#1419
Comments
Actually LSP has no support for Could you explain the use case why you think that should flow to the server? |
This came up in a discussion with @rebornix when we were going over each field in |
Actually formatting a notebook (e.g. ordering the cells) might not be something a LSP server should do. I think a LSP server should be able to format a code cell of a specific language. If we have a notebook with TypeScript, C# and Python cells which language server should be responsible to format the overall notebook? |
Formatting tools like Think import organizer pulling all the import statements from various cells into a top cell that just does all imports? Code refactoring that splits or combines cells of some language. Currently all of this is being done by writing the notebook to disk after formatting. @rebornix and I are thinking about the selecting a overall formatter. Since the current |
I think we need to keep two things apart:
|
Put outputs and ployglot aside (for now), I personally find that there is a need for notebook level language support. It's between project/workspace and single file, notebook formatting and code actions are two good examples where the language server needs to know about the context of notebooks and might need to adjust the notebook document accordingly. I'm imagining scenarios: users work on Python or Julia or C# notebook (single language) document, and they want the document to be formatted as a whole (e.g., imports are all moved to the first cell). Current LSP messages/types can't express this though. |
I want to clarify that when I mentioned If the formatting tool decides to add/remove cells then I think we need to allow this to occur over LSP. |
Hi, chiming in as the author of the PR implementing Notebook support in From what I understood from this conversation, and correct me if I'm wrong, is that "formatting" in this context is referred not just for code formatting (like Now, I just want to clarify how The reason for this process is that there's no official support for Notebook document formatting ( And, if someone invokes the Does this help? Feel free to ping me with any other questions or input as required :) |
@dhruvmanila the issue is that if you use One of the asked for features for formatting in the black/autopep8/isort extension repos is to properly support formatting for |
What is describe doesn't sound like formatting to me (not in the sense as we use formatting in VS Code). It sounds more like code actions. And I am not sure if we should add this to LSP since it would require to mirror the whole Notebook structure inclusive NotebookEdits into LSP. What I could think about is a Notebook protocol which is based on the BaseProtocol (see: https://microsoft.github.io/language-server-protocol/specifications/base/0.9/specification/) which would allow a server to acts as both a language server and a notebook server. |
Since it's still evolving pretty fast (we had notebook code actions in VS Code a few months ago and now we are exploring notebook level formatting), I wonder we can firstly try custom messages but craft a spec for it. With @karthiknadig 's auto code generation tool, we can auto build libraries for notebook-specific protocol, which work like plugins to the existing standard LSP libraries. Then language servers like from notebooklsprotocol.types import (
NOTEBOOK_DOCUMENT_FORMATTING
} if we see common interest on it, we can then make it a real notebook protocol. |
Some tips: both the client and the server supports feature you can plug into them (@rebornix is this what you refer to as plugins?). This allows to develop new features outside of this repository but already have some nice way to integrate them since they participate on the client and server side in things like capabilities initialization. If you need support with feel free to ping. |
Yes this is accurate. I like this approach! |
(Sorry for the late reply.)
As @dbaeumer pointed out, I'm not sure if making structural changes sounds like formatting. Although, if a cell contains only imports that are unused, then we might as well delete the entire cell.
If I understand this correctly, this will kind off be like an experimental feature which the server can opt-in. I like this approach as well. |
Sorry for overloading "formatting", my concern was that currently there is no way to add or remove cells. The core I also understand there is larger issue of document selection, to associate with a particular language server, and how the notebook itself is handled, as in the notebook server case. Currently, I think we can improve the experience with notebooks. If we can define it as an extension over LSP using similar schema, we could generate the types for easier consumption by existing language servers for narrow cases like single language notebooks. The |
See
vscode.d.ts
: https://github.com/microsoft/vscode/blob/ad05897293964be52ad97505124830937d096953/src/vscode-dts/vscode.d.ts#L14441vscode-languageserver-node/protocol/metaModel.json
Lines 9949 to 9989 in 12d1b72
The text was updated successfully, but these errors were encountered: