Description
This is a meta tracking issue to enable support for notebook formatting using a provider API and adding support to LSP.
Overview
Currently notebook formatting changes can be applied via WorkspaceEdit
using NotebookEdit
(for the entire notebook) and NotebookCellData
(for individual cells). There is no provider registration mechanism and no way to do this over LSP.
Notebook formatting provider
Add a notebook formatting provider similar to registerDocumentFormattingEditProvider
to core. Consider notebook document selector for the provider, similar to document selector. Use DocumentSelector.notebookType
for selecting notebooks.
See LSP notebook filter: https://github.com/microsoft/vscode-languageserver-node/blob/12d1b72b7ba35746f15645c408a6bffbbc19102c/protocol/metaModel.json#L15390-L15411
- spike: Do you need additional fields for notebook language.
- Add provider API to core
Notebook formatting setting
Consider if a setting similar to editor.defaultFormatter
to select formatting provider for notebooks is needed. If yes then it will also need a UI similar to the selections provided by document formatters and fallback mechanism when none are provided.
- spike: how should this setting be scoped, think python notebook, and ,net notebook. A notebook formatter for python notebooks might not work for .net. The inverse can also be true, a language agnostic notebook formatter, how to select or set either.
- Settings for formatting notebooks (e.g.,
notebook.defaultFormater
)
notebook.format
command updates
This command should look for formatters registered via provider. Provide a fallback behavior similar to what we have today.
- spike: Picking the right notebook formatter to do the notebook formatting.
- look for formatting providers when handling
notebook.format
Consider progress support for notebook formatting provider API
Typically formatting notebooks can take longer than formatting a single document. Consider support for progress reporting.
- Consider progress reporting for notebook formatting. Similar to Text Search.
Notebook formatting capability in LSP
Update LSP client to use notebook capability to register notebook formatting provider, with notebook formatting options. Update the server/client capabilities, and types as needed for formatting. Update the LSP meta model for to include types needed for Notebook edit, and cell edit.
The document formatting variant of this currently only exposes work done progress, but this is not supported in the UI for VS Code. We may want to consider supporting a progress API as notebook formatting can take long.
- Add notebook formatting types and register provider in LSP : Add support for
NotebookEdit
inWorkspaceEdit
vscode-languageserver-node#1336
/cc @rebornix
Activity