Add REPL dropdown menu to toolbar (#14493)

TODO: 


- [x] Actions run from menu not firing
- [x] Menu differentiates idle and busy for running kernel

Menu States:
- [x] No session && no support known

No session && no kernel installed for languages of known support
- (TODO after) Intro to REPL
- [x] Link to docs

No session but can start one
- [x] Start REPL
- (TODO after) More info -> Docs?

Yes Session

- [x] Info: Kernel name, language
  example: chatlab-3.7-adsf87fsa (Python)
  example: condapy-3.7 (Python)
- [x] Change Kernel -> https://zed.dev/docs/repl#change-kernel
- ---
- [x] Run
- [x] Interrupt
- [x] Clear Outputs
- ---
- [x] Shutdown


(Release notes left empty as the change will be documented in the REPL
release!)

Reserved for a follow on PR:

```
- [ ] Status should update when the menu is open (missing `cx.notify`?)
- [ ] Shutdown all kernels action
- [ ] Restart action
- [ ] [Default kernel changed - restart (this kernel) to apply] // todo!(kyle): need some kind of state thing that says if this has happened
```


Release Notes:

- N/A

---------

Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
Co-authored-by: Kyle Kelley <rgbkrk@gmail.com>
Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com>
This commit is contained in:
Nate Butler 2024-07-15 14:55:49 -04:00 committed by GitHub
parent 1856320516
commit fa3d29087d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 489 additions and 71 deletions

View file

@ -8,12 +8,13 @@ This feature is in active development. Details may change. We're delighted to ge
</div>
## Getting started
The built-in REPL for Zed allows you to run code interactively in your editor similarly to a notebook with your own text files.
Bring the power of [Jupyter kernels](https://docs.jupyter.org/en/latest/projects/kernels.html) to your editor! The built-in REPL for Zed allows you to run code interactively in your editor similarly to a notebook with your own text files.
<!-- TODO: Include GIF in action -->
To start using the REPL, add the following to your Zed `settings.json` to bring the power of [Jupyter kernels](https://docs.jupyter.org/en/latest/projects/kernels.html) to your editor:
To start using the REPL, add the following to your Zed `settings.json`:
```json
{
@ -23,22 +24,53 @@ To start using the REPL, add the following to your Zed `settings.json` to bring
}
```
After that, install any of the supported kernels:
## Installation
* [Python](#python)
* [TypeScript via Deno](#deno)
Zed supports running code in multiple languages. To get started, you need to install a kernel for the language you want to use.
## Python
**Currently supported languages:**
* [Python (ipykernel)](#python)
* [TypeScript (Deno)](#typescript-deno)
Once installed, you can start using the REPL in the respective language files, or other places those languages are supported, such as Markdown.
<!-- TODO: Make markdown a link with an example -->
## Using the REPL
To start the REPL, open a file with the language you want to use and use the `repl: run` command (defaults to CMD + Enter on macOS). You can also click on the REPL icon in the toolbar.
The `repl: run` command will be executed on your selection(s), and the result will be displayed below the selection.
Outputs can be cleared with the `repl: clear outputs` command, or from the REPL menu in the toolbar.
## Changing Kernels {#changing-kernels}
Work in Progress!
## Language specific instructions
### Python {#python}
#### Global environment
<div class="warning">
On MacOS, your system Python will _not_ work. Either set up [pyenv](https://github.com/pyenv/pyenv?tab=readme-ov-file#installation) or use a virtual environment.
</div>
### Global environment
To setup your current python to have an available kernel, run:
```
pip install ipykernel
python -m ipykernel install --user
```
### Conda Environment
#### Conda Environment
```
source activate myenv
@ -47,7 +79,7 @@ python -m ipykernel install --user --name myenv --display-name "Python (myenv)"
```
### Virtualenv with pip
#### Virtualenv with pip
```
source activate myenv
@ -55,7 +87,7 @@ pip install ipykernel
python -m ipykernel install --user --name myenv --display-name "Python (myenv)"
```
## Deno
### Typescript: Deno {#typescript-deno}
[Install Deno](https://docs.deno.com/runtime/manual/getting_started/installation/) and then install the Deno jupyter kernel:
@ -63,10 +95,12 @@ python -m ipykernel install --user --name myenv --display-name "Python (myenv)"
deno jupyter --unstable --install
```
## Other languages
### Other languages
* [Julia](https://github.com/JuliaLang/IJulia.jl)
The following languages and kernels are also supported. You can help us out by expanding their installation instructions and configuration:
* [Julia (IJulia)](https://github.com/JuliaLang/IJulia.jl)
* R
- [Ark Kernel from Positron, formerly RStudio](https://github.com/posit-dev/ark)
- [Ark Kernel](https://github.com/posit-dev/ark) - via Positron, formerly RStudio
- [Xeus-R](https://github.com/jupyter-xeus/xeus-r)
* [Scala](https://almond.sh/docs/quick-start-install)
* [Scala (almond)](https://almond.sh/docs/quick-start-install)