posit-dev / positron

Positron, a next-generation data science IDE
https://positron.posit.co
Other
2.59k stars 79 forks source link

Epic: Positron Notebook Editor Basic #2263

Open nstrayer opened 8 months ago

nstrayer commented 8 months ago

What?

A new editor for notebook applications. The "basic" setup will be the minimum needed for a functional notebook experience. This won't necessarily result in a better notebook experience than the built-in vscode notebooks, but will be the foundation for building off of to create a better experience.

Steps

cscheid commented 2 months ago

One feature that came up today is the ability for YAML autocompletion and validation to work within the Notebook editor. RStudio and Quarto's VS code extension do stuff like this:

image

The validation uses precisely the same schema as the command line, and it also drives auto-completion when appropriate, again from the same sources:

image

The Positron notebook editor can, at least in principle, detect Quarto metadata blocks, and it would be nice for it to provide the same affordances.

This code is sort of factored out already in a way that is accessible to RStudio and VS Code both. It's not pretty, but the way this works is that quarto-cli bundles (among other things) a Javascript file that has an API for querying completions and validations. Since the VS code extension and RStudio both know where quarto is, they can access this file, and they know how to call it.

The files are all in ./src/resources/editor/tools/yaml/ inside a bundle, as well as https://github.com/quarto-dev/quarto-cli/tree/main/src/resources/editor/tools/yaml. The entry points themselves are:

https://github.com/quarto-dev/quarto-cli/blob/05295257c854214900910847cf6bc4faf7ecdcf1/src/resources/editor/tools/yaml/yaml-intelligence.js#L98

This is all messy (insert banana guy meme here), but a pairing session should be enough for y'all to get your bearings.

cscheid commented 2 months ago

Another thing that the VS code editor does is auto-completion for some Markdown constructs directly:

image

This would also be nice to have support for in the Notebook editor. These completions are defined in

https://github.com/quarto-dev/quarto-cli/blob/05295257c854214900910847cf6bc4faf7ecdcf1/src/resources/editor/tools/attrs.yml

And they are used by the VS Code extension in

https://github.com/quarto-dev/quarto/blob/b6c819b0b3649d6011a8fff06532107b5a3ebbab/apps/lsp/src/quarto.ts#L84-L162