2024-07-10 16:20:52 +00:00
# REPL
2024-07-15 18:55:49 +00:00
## Getting started
2024-07-10 16:20:52 +00:00
2024-07-24 07:50:23 +00:00
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.
2024-07-10 16:20:52 +00:00
<!-- TODO: Include GIF in action -->
2024-07-15 18:55:49 +00:00
## Installation
2024-07-10 16:20:52 +00:00
2024-07-15 18:55:49 +00:00
Zed supports running code in multiple languages. To get started, you need to install a kernel for the language you want to use.
2024-07-10 16:20:52 +00:00
2024-07-15 18:55:49 +00:00
**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
2024-07-24 07:50:23 +00:00
To start the REPL, open a file with the language you want to use and use the `repl: run` command (defaults to `ctrl-shift-enter` on macOS). You can also click on the REPL icon in the toolbar.
2024-07-15 18:55:49 +00:00
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.
## 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 >
2024-07-10 16:20:52 +00:00
To setup your current python to have an available kernel, run:
```
2024-07-15 18:55:49 +00:00
pip install ipykernel
2024-07-10 16:20:52 +00:00
python -m ipykernel install --user
```
2024-07-15 18:55:49 +00:00
#### Conda Environment
2024-07-10 16:20:52 +00:00
```
source activate myenv
conda install ipykernel
python -m ipykernel install --user --name myenv --display-name "Python (myenv)"
```
2024-07-15 18:55:49 +00:00
#### Virtualenv with pip
2024-07-10 16:20:52 +00:00
```
source activate myenv
pip install ipykernel
python -m ipykernel install --user --name myenv --display-name "Python (myenv)"
```
2024-07-15 18:55:49 +00:00
### Typescript: Deno {#typescript-deno}
2024-07-10 16:20:52 +00:00
[Install Deno ](https://docs.deno.com/runtime/manual/getting_started/installation/ ) and then install the Deno jupyter kernel:
```
2024-07-23 18:03:22 +00:00
deno jupyter --install
2024-07-10 16:20:52 +00:00
```
2024-07-15 18:55:49 +00:00
### Other languages
The following languages and kernels are also supported. You can help us out by expanding their installation instructions and configuration:
2024-07-10 16:20:52 +00:00
2024-07-15 18:55:49 +00:00
* [Julia (IJulia) ](https://github.com/JuliaLang/IJulia.jl )
2024-07-10 16:20:52 +00:00
* R
2024-07-15 18:55:49 +00:00
- [Ark Kernel ](https://github.com/posit-dev/ark ) - via Positron, formerly RStudio
2024-07-10 16:20:52 +00:00
- [Xeus-R ](https://github.com/jupyter-xeus/xeus-r )
2024-07-15 18:55:49 +00:00
* [Scala (almond) ](https://almond.sh/docs/quick-start-install )
2024-07-23 18:03:22 +00:00
## Changing which kernel is used per language {#changing-kernels}
Zed automatically detects the available kernels on your system. If you need to configure a different default kernel for a
language, you can assign a kernel for any supported language in your `settings.json` .
```jsonc
{
"jupyter": {
"kernel_selections": {
"python": "conda-env",
"typescript": "deno",
"javascript": "deno"
}
}
}
```
If you have `jupyter` installed, you can run `jupyter kernelspec list` to see the available kernels.
```
$ jupyter kernelspec list
Available kernels:
ark /Users/z/Library/Jupyter/kernels/ark
conda-base /Users/z/Library/Jupyter/kernels/conda-base
deno /Users/z/Library/Jupyter/kernels/deno
python-chatlab-dev /Users/z/Library/Jupyter/kernels/python-chatlab-dev
python3 /Users/z/Library/Jupyter/kernels/python3
ruby /Users/z/Library/Jupyter/kernels/ruby
rust /Users/z/Library/Jupyter/kernels/rust
```
Note: Zed will not find kernels nested within your Python `sys.prefix` , shown here as `/Users/z/.pyenv/versions/miniconda3-latest/` .
```
$ jupyter kernelspec list
Available kernels:
conda-base /Users/z/Library/Jupyter/kernels/conda-base
python3 /Users/z/.pyenv/versions/miniconda3-latest/share/jupyter/kernels/python3
```
You must run `python -m ipykernel install --user` to install the kernel.