Skip to content
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

Meta: Notebook formatting API #204544

Open
8 tasks
karthiknadig opened this issue Feb 6, 2024 · 0 comments
Open
8 tasks

Meta: Notebook formatting API #204544

karthiknadig opened this issue Feb 6, 2024 · 0 comments
Assignees
Labels
feature-request Request for new features or functionality notebook-format Formatting support for notebooks

Comments

@karthiknadig
Copy link
Member

karthiknadig commented Feb 6, 2024

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.

/cc @rebornix

@karthiknadig karthiknadig added feature-request Request for new features or functionality notebook-format Formatting support for notebooks labels Feb 6, 2024
@karthiknadig karthiknadig self-assigned this Feb 6, 2024
@karthiknadig karthiknadig removed their assignment Feb 21, 2024
@rebornix rebornix assigned Yoyokrazy and unassigned rebornix Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality notebook-format Formatting support for notebooks
Projects
None yet
Development

No branches or pull requests

3 participants