repl.md

  1# REPL
  2
  3Read. Eval. Print. Loop.
  4
  5<div class="warning">
  6
  7This feature is in active development. Details may change. We're delighted to get feedback as the REPL feature evolves.
  8
  9</div>
 10
 11## Getting started
 12
 13Bring 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.
 14
 15<!-- TODO: Include GIF in action -->
 16
 17To start using the REPL, add the following to your Zed `settings.json`:
 18
 19```json
 20{
 21  "jupyter": {
 22    "enabled": true
 23  }
 24}
 25```
 26
 27## Installation
 28
 29Zed supports running code in multiple languages. To get started, you need to install a kernel for the language you want to use.
 30
 31**Currently supported languages:**
 32
 33* [Python (ipykernel)](#python)
 34* [TypeScript (Deno)](#typescript-deno)
 35
 36
 37Once installed, you can start using the REPL in the respective language files, or other places those languages are supported, such as Markdown.
 38
 39<!-- TODO: Make markdown a link with an example -->
 40
 41## Using the REPL
 42
 43To 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.
 44
 45The `repl: run` command will be executed on your selection(s), and the result will be displayed below the selection.
 46
 47Outputs can be cleared with the `repl: clear outputs` command, or from the REPL menu in the toolbar.
 48
 49## Changing Kernels {#changing-kernels}
 50
 51Work in Progress!
 52
 53## Language specific instructions
 54
 55### Python {#python}
 56
 57#### Global environment
 58
 59<div class="warning">
 60
 61On 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.
 62
 63</div>
 64
 65
 66To setup your current python to have an available kernel, run:
 67
 68```
 69pip install ipykernel
 70python -m ipykernel install --user
 71```
 72
 73#### Conda Environment
 74
 75```
 76source activate myenv
 77conda install ipykernel
 78python -m ipykernel install --user --name myenv --display-name "Python (myenv)"
 79```
 80
 81
 82#### Virtualenv with pip
 83
 84```
 85source activate myenv
 86pip install ipykernel
 87python -m ipykernel install --user --name myenv --display-name "Python (myenv)"
 88```
 89
 90### Typescript: Deno {#typescript-deno}
 91
 92[Install Deno](https://docs.deno.com/runtime/manual/getting_started/installation/) and then install the Deno jupyter kernel:
 93
 94```
 95deno jupyter --unstable --install
 96```
 97
 98### Other languages
 99
100The following languages and kernels are also supported. You can help us out by expanding their installation instructions and configuration:
101
102* [Julia (IJulia)](https://github.com/JuliaLang/IJulia.jl)
103* R
104  - [Ark Kernel](https://github.com/posit-dev/ark) - via Positron, formerly RStudio
105  - [Xeus-R](https://github.com/jupyter-xeus/xeus-r)
106* [Scala (almond)](https://almond.sh/docs/quick-start-install)