completions.md

  1# Completions
  2
  3Zed supports two sources for completions:
  4
  51. "Code Completions" provided by Language Servers (LSPs) automatically installed by Zed or via [Zed Language Extensions](languages.md).
  62. "Edit Predictions" provided by Zed's own Zeta model or by external providers like [GitHub Copilot](#github-copilot) or [Supermaven](#supermaven).
  7
  8## Language Server Code Completions {#code-completions}
  9
 10When there is an appropriate language server available, Zed will provide completions of variable names, functions, and other symbols in the current file. You can disable these by adding the following to your Zed `settings.json` file:
 11
 12```json
 13"show_completions_on_input": false
 14```
 15
 16You can manually trigger completions with `ctrl-space` or by triggering the `editor::ShowCompletions` action from the command palette.
 17
 18For more information, see:
 19
 20- [Configuring Supported Languages](./configuring-languages.md)
 21- [List of Zed Supported Languages](./languages.md).
 22
 23## Edit Predictions {#edit-predictions}
 24
 25Zed has built-in support for predicting multiple edits at a time via its [Zeta model](https://huggingface.co/zed-industries/zeta). Clicking "Introducing: Edit Prediction" on the top right will open a brief prompt setting up this feature.
 26
 27Edit predictions appear as you type, and you can accept them by pressing `tab`. The `tab` key is already used for accepting language server completions and for indenting. In these cases, `alt-tab` is used instead to accept the prediction. When the completions menu is open, holding `alt` will cause it to temporarily disappear in order to view the prediction within the buffer.
 28
 29On Linux, `alt-tab` is often used by the window manager for switching windows, so `alt-l` is provided as the default binding for accepting predictions. `tab` and `alt-tab` also work, but aren't displayed by default.
 30
 31{#action editor::AcceptPartialEditPrediction} ({#kb editor::AcceptPartialEditPrediction}) can be used to accept the current edit prediction up to the next word boundary.
 32
 33See the [Configuring GitHub Copilot](#github-copilot) and [Configuring Supermaven](#supermaven) sections below for configuration of other providers. Only text insertions at the current cursor are supported for these providers, whereas the Zeta model provides multiple predictions including deletions.
 34
 35## Configuring Edit Prediction Keybindings
 36
 37By default, `tab` is used to accept edit predictions. You can use another keybinding by inserting this in your keymap:
 38
 39```json
 40{
 41  "context": "Editor && edit_prediction",
 42  "bindings": {
 43    // Here we also allow `alt-enter` to accept the prediction
 44    "alt-enter": "editor::AcceptEditPrediction"
 45  }
 46}
 47```
 48
 49When you have both a language server completion and an edit prediction on screen at the same time, Zed uses a different context to accept keybindings (`edit_prediction_conflict`). If you want to use a different keybinding, you can insert this in your keymap:
 50
 51```json
 52{
 53  "context": "Editor && edit_prediction_conflict",
 54  "bindings": {
 55    "ctrl-enter": "editor::AcceptEditPrediction"
 56  }
 57}
 58```
 59
 60If your keybinding contains a modifier (`ctrl` in the example), it will be used to preview the edit prediction and temporarily hide the language server completion menu.
 61
 62You can also bind a keystroke without a modifier. In that case, Zed will use the default modifier (`alt`) to preview the edit prediction.
 63
 64```json
 65{
 66  "context": "Editor && edit_prediction_conflict",
 67  "bindings": {
 68    // Here we bind tab to accept even when there's a language server completion
 69    "tab": "editor::AcceptEditPrediction"
 70  }
 71}
 72```
 73
 74### Keybinding Example: Always Use Alt-Tab
 75
 76The keybinding example below causes `alt-tab` to always be used instead of sometimes using `tab`. You might want this in order to have just one keybinding to use for accepting edit predictions, since the behavior of `tab` varies based on context.
 77
 78```json
 79  {
 80    "context": "Editor && edit_prediction",
 81    "bindings": {
 82      "alt-tab": "editor::AcceptEditPrediction"
 83    }
 84  },
 85  // Bind `tab` back to its original behavior.
 86  {
 87    "context": "Editor",
 88    "bindings": {
 89      "tab": "editor::Tab"
 90    }
 91  },
 92  {
 93    "context": "Editor && showing_completions",
 94    "bindings": {
 95      "tab": "editor::ComposeCompletion"
 96    }
 97  },
 98```
 99
100If `"vim_mode": true` is set within `settings.json`, then additional bindings are needed after the above to return `tab` to its original behavior:
101
102```json
103  {
104    "context": "(VimControl && !menu) || vim_mode == replace || vim_mode == waiting",
105    "bindings": {
106      "tab": "vim::Tab"
107    }
108  },
109  {
110    "context": "vim_mode == literal",
111    "bindings": {
112      "tab": ["vim::Literal", ["tab", "\u0009"]]
113    }
114  },
115```
116
117### Keybinding Example: Displaying Tab and Alt-Tab on Linux
118
119While `tab` and `alt-tab` are supported on Linux, `alt-l` is displayed instead. If your window manager does not reserve `alt-tab`, and you would prefer to use `tab` and `alt-tab`, include these bindings in `keymap.json`:
120
121```json
122  {
123    "context": "Editor && edit_prediction",
124    "bindings": {
125      "tab": "editor::AcceptEditPrediction",
126      // Optional: This makes the default `alt-l` binding do nothing.
127      "alt-l": null
128    }
129  },
130  {
131    "context": "Editor && edit_prediction_conflict",
132    "bindings": {
133      "alt-tab": "editor::AcceptEditPrediction",
134      // Optional: This makes the default `alt-l` binding do nothing.
135      "alt-l": null
136    }
137  },
138```
139
140## Disabling Automatic Edit Prediction
141
142To disable predictions that appear automatically as you type, set this within `settings.json`:
143
144```json
145{
146  "show_edit_predictions": false
147}
148```
149
150You can trigger edit predictions manually by executing {#action editor::ShowEditPrediction} ({#kb editor::ShowEditPrediction}).
151
152You can also add this as a language-specific setting in your `settings.json` to disable edit predictions for a specific language:
153
154```json
155{
156  "language": {
157    "python": {
158      "show_edit_predictions": false
159    }
160  }
161}
162```
163
164## Configuring GitHub Copilot {#github-copilot}
165
166To use GitHub Copilot, set this within `settings.json`:
167
168```json
169{
170  "features": {
171    "edit_prediction_provider": "copilot"
172  }
173}
174```
175
176You should be able to sign-in to GitHub Copilot by clicking on the Copilot icon in the status bar and following the setup instructions.
177
178Copilot can provide multiple completion alternatives, and these can be navigated with the following actions:
179
180- {#action editor::NextEditPrediction} ({#kb editor::NextEditPrediction}): To cycle to the next edit prediction
181- {#action editor::PreviousEditPrediction} ({#kb editor::PreviousEditPrediction}): To cycle to the previous edit prediction
182
183## Configuring Supermaven {#supermaven}
184
185To use Supermaven, set this within `settings.json`:
186
187```json
188{
189  "features": {
190    "edit_prediction_provider": "supermaven"
191  }
192}
193```
194
195You should be able to sign-in to Supermaven by clicking on the Supermaven icon in the status bar and following the setup instructions.
196
197## See also
198
199You may also use the Assistant Panel or the Inline Assistant to interact with language models, see the [assistant](assistant/assistant.md) documentation for more information.