| 1 | --- |
| 2 | title: "Context Selection" |
| 3 | description: "Learn how Continue's autocomplete selects relevant code context using file content, language server definitions, imports, and recent file history." |
| 4 | --- |
| 5 | |
| 6 | Autocomplete will automatically determine context based on the current cursor position. We use the following techniques to determine what to include in the prompt: |
| 7 | |
| 8 | ## File Prefix and Suffix Context |
| 9 | |
| 10 | We will always include the code from your file prior to and after the cursor position. |
| 11 | |
| 12 | ## Language Server Protocol (LSP) Definitions |
| 13 | |
| 14 | Similar to how you can use cmd/ctrl + click in your editor, we use the same tool (the LSP) to power "go to definition". For example, if you are typing out a function call, we will include the function definition. Or, if you are writing code inside of a method, we will include the type definitions for any parameters or the return type. |
| 15 | |
| 16 | ## Imported File Context |
| 17 | |
| 18 | Because there are often many imports, we can't include all of them. Instead, we look for symbols around your cursor that have matching imports and use that as context. |
| 19 | |
| 20 | ## Recent File Context |
| 21 | |
| 22 | We automatically consider recently opened or edited files and include snippets that are relevant to the current completion. |