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
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.
notebook.format command updates
This command should look for formatters registered via provider. Provide a fallback behavior similar to what we have today.
Consider progress support for notebook formatting provider API
Typically formatting notebooks can take longer than formatting a single document. Consider support for progress reporting.
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.
/cc @rebornix
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
WorkspaceEditusingNotebookEdit(for the entire notebook) andNotebookCellData(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
registerDocumentFormattingEditProviderto core. Consider notebook document selector for the provider, similar to document selector. UseDocumentSelector.notebookTypefor selecting notebooks.See LSP notebook filter: https://github.com/microsoft/vscode-languageserver-node/blob/12d1b72b7ba35746f15645c408a6bffbbc19102c/protocol/metaModel.json#L15390-L15411
Notebook formatting setting
Consider if a setting similar to
editor.defaultFormatterto 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.notebook.defaultFormater)notebook.formatcommand updatesThis command should look for formatters registered via provider. Provide a fallback behavior similar to what we have today.
notebook.formatConsider progress support for notebook formatting provider API
Typically formatting notebooks can take longer than formatting a single document. Consider support for progress reporting.
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.
NotebookEditinWorkspaceEditvscode-languageserver-node#1336/cc @rebornix