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 Zeta](https://huggingface.co/zed-industries/zeta), Zed's open-source and open-data model.
26Edit predictions appear as you type, and most of the time, you can accept them by pressing `tab`.
27
28### Configuring Zeta
29
30Zed's Edit Prediction was initially introduced via a banner on the title bar.
31Clicking on it would take you to a modal with a button ("Enable Edit Prediction") that sets `zed` as your `edit_prediction_provider`.
32
33
34
35But, if you haven't come across the banner, Zed's Edit Prediction is the default edit prediction provider and you should see it right away in your status bar.
36
37### Switching modes {#switching-modes}
38
39Zed's Edit Prediction comes with two different display modes:
40
411. `eager` (default): predictions are displayed inline as long as it doesn't conflict with language server completions
422. `subtle`: predictions only appear inline when holding a modifier key (`alt` by default)
43
44Toggle between them via the `mode` key:
45
46```json
47"edit_predictions": {
48 "mode": "eager" | "subtle"
49},
50```
51
52### Conflict With Other `tab` Actions {#edit-predictions-conflict}
53
54By default, when `tab` would normally perform a different action, Zed requires a modifier key to accept predictions:
55
561. When the language server completions menu is visible.
572. When your cursor isn't at the right indentation level.
58
59In these cases, `alt-tab` is used instead to accept the prediction. When the language server completions menu is open, holding `alt` first will cause it to temporarily disappear in order to preview the prediction within the buffer.
60
61On 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.
62
63{#action editor::AcceptPartialEditPrediction} ({#kb editor::AcceptPartialEditPrediction}) can be used to accept the current edit prediction up to the next word boundary.
64
65See 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.
66
67## Configuring Edit Prediction Keybindings {#edit-predictions-keybinding}
68
69By default, `tab` is used to accept edit predictions. You can use another keybinding by inserting this in your keymap:
70
71```json
72{
73 "context": "Editor && edit_prediction",
74 "bindings": {
75 // Here we also allow `alt-enter` to accept the prediction
76 "alt-enter": "editor::AcceptEditPrediction"
77 }
78}
79```
80
81When there's a [conflict with the `tab` key](#edit-predictions-conflict), Zed uses a different context to accept keybindings (`edit_prediction_conflict`). If you want to use a different one, you can insert this in your keymap:
82
83```json
84{
85 "context": "Editor && edit_prediction_conflict",
86 "bindings": {
87 "ctrl-enter": "editor::AcceptEditPrediction" // Example of a modified keybinding
88 }
89}
90```
91
92If your keybinding contains a modifier (`ctrl` in the example above), it will also be used to preview the edit prediction and temporarily hide the language server completion menu.
93
94You can also bind this action to keybind without a modifier. In that case, Zed will use the default modifier (`alt`) to preview the edit prediction.
95
96```json
97{
98 "context": "Editor && edit_prediction_conflict",
99 "bindings": {
100 // Here we bind tab to accept even when there's a language server completion
101 // or the cursor isn't at the correct indentation level
102 "tab": "editor::AcceptEditPrediction"
103 }
104}
105```
106
107To maintain the use of the modifier key for accepting predictions when there is a language server completions menu, but allow `tab` to accept predictions regardless of cursor position, you can specify the context further with `showing_completions`:
108
109```json
110{
111 "context": "Editor && edit_prediction_conflict && !showing_completions",
112 "bindings": {
113 // Here we don't require a modifier unless there's a language server completion
114 "tab": "editor::AcceptEditPrediction"
115 }
116}
117```
118
119### Keybinding Example: Always Use Alt-Tab
120
121The 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.
122
123```json
124 {
125 "context": "Editor && edit_prediction",
126 "bindings": {
127 "alt-tab": "editor::AcceptEditPrediction"
128 }
129 },
130 // Bind `tab` back to its original behavior.
131 {
132 "context": "Editor",
133 "bindings": {
134 "tab": "editor::Tab"
135 }
136 },
137 {
138 "context": "Editor && showing_completions",
139 "bindings": {
140 "tab": "editor::ComposeCompletion"
141 }
142 },
143```
144
145If `"vim_mode": true` is set within `settings.json`, then additional bindings are needed after the above to return `tab` to its original behavior:
146
147```json
148 {
149 "context": "(VimControl && !menu) || vim_mode == replace || vim_mode == waiting",
150 "bindings": {
151 "tab": "vim::Tab"
152 }
153 },
154 {
155 "context": "vim_mode == literal",
156 "bindings": {
157 "tab": ["vim::Literal", ["tab", "\u0009"]]
158 }
159 },
160```
161
162### Keybinding Example: Displaying Tab and Alt-Tab on Linux
163
164While `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`:
165
166```json
167 {
168 "context": "Editor && edit_prediction",
169 "bindings": {
170 "tab": "editor::AcceptEditPrediction",
171 // Optional: This makes the default `alt-l` binding do nothing.
172 "alt-l": null
173 }
174 },
175 {
176 "context": "Editor && edit_prediction_conflict",
177 "bindings": {
178 "alt-tab": "editor::AcceptEditPrediction",
179 // Optional: This makes the default `alt-l` binding do nothing.
180 "alt-l": null
181 }
182 },
183```
184
185### Missing keybind {#edit-predictions-missing-keybinding}
186
187Zed requires at least one keybinding for the {#action editor::AcceptEditPrediction} action in both the `Editor && edit_prediction` and `Editor && edit_prediction_conflict` contexts ([learn more above](#edit-predictions-keybinding)).
188
189If you have previously bound the default keybindings to different actions in the global context, you will not be able to preview or accept edit predictions. For example:
190
191```json
192[
193 // Your keymap
194 {
195 "bindings": {
196 // Binds `alt-tab` to a different action globally
197 "alt-tab": "menu::SelectNext"
198 }
199 }
200]
201```
202
203To fix this, you can specify your own keybinding for accepting edit predictions:
204
205```json
206[
207 // ...
208 {
209 "context": "Editor && edit_prediction_conflict",
210 "bindings": {
211 "alt-l": "editor::AcceptEditPrediction"
212 }
213 }
214]
215```
216
217If you would like to use the default keybinding, you can free it up by either moving yours to a more specific context or changing it to something else.
218
219## Disabling Automatic Edit Prediction
220
221To not have predictions appear automatically as you type, set this within `settings.json`:
222
223```json
224{
225 "show_edit_predictions": false
226}
227```
228
229You can trigger edit predictions manually by executing {#action editor::ShowEditPrediction} ({#kb editor::ShowEditPrediction}).
230
231You can also add this as a language-specific setting in your `settings.json` to disable edit predictions for a specific language:
232
233```json
234{
235 "language": {
236 "python": {
237 "show_edit_predictions": false
238 }
239 }
240}
241```
242
243Alternatively, if you're using Zed's Edit Prediction, you can [use Subtle Mode](/#switching-modes).
244
245### Turning Off Completely
246
247To completely turn off edit prediction across all providers, explicitly set the settings to `none`, like so:
248
249```json
250"features": {
251 "edit_prediction_provider": "none"
252},
253```
254
255## Configuring GitHub Copilot {#github-copilot}
256
257To use GitHub Copilot, set this within `settings.json`:
258
259```json
260{
261 "features": {
262 "edit_prediction_provider": "copilot"
263 }
264}
265```
266
267You should be able to sign-in to GitHub Copilot by clicking on the Copilot icon in the status bar and following the setup instructions.
268
269Copilot can provide multiple completion alternatives, and these can be navigated with the following actions:
270
271- {#action editor::NextEditPrediction} ({#kb editor::NextEditPrediction}): To cycle to the next edit prediction
272- {#action editor::PreviousEditPrediction} ({#kb editor::PreviousEditPrediction}): To cycle to the previous edit prediction
273
274## Configuring Supermaven {#supermaven}
275
276To use Supermaven, set this within `settings.json`:
277
278```json
279{
280 "features": {
281 "edit_prediction_provider": "supermaven"
282 }
283}
284```
285
286You should be able to sign-in to Supermaven by clicking on the Supermaven icon in the status bar and following the setup instructions.
287
288## See also
289
290You 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.