Autocomplete will automatically determine context based on the current cursor position. We use the following techniques to determine what to include in the prompt:
We will always include the code from your file prior to and after the cursor position.
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.
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.
We automatically consider recently opened or edited files and include snippets that are relevant to the current completion.