Context-aware auto-complete

How it worksContext-aware matchingAccepting completionsAuto-complete and AI completionWhy?

Complete words and identifiers using suggestions from the current file.

context-aware-auto-complete-sm.webp

Koi indexes the text you're editing and uses it to suggest identifiers, names, and other words that already appear in the document.

Unlike code completion⁠, auto-complete doesn't generate new code or require a model. Suggestions come directly from the current file.

How it works

The file is indexed when it is opened and saved. Modified lines are reindexed while you edit, so suggestions include unsaved changes.

As you type, Koi searches that index and ranks possible completions using the surrounding context and fuzzy matching. This works for source code as well as ordinary text.

Context-aware matching

Auto-complete isn't limited to exact prefix matches. Fuzzy matching can find words when you only remember part of a name or when what you've typed is close to an existing match.

When several suggestions are possible, the surrounding text helps determine which ones appear first. Because suggestions come from the document itself, project-specific identifiers, terminology, names, and repeated phrases naturally become available as you work.

Accepting completions

Suggestions do not modify the document until you accept them.

By default, auto-complete uses the newline command. This means ⏎ Return accepts a visible suggestion before inserting a new line.

If no suggestion is visible, the command behaves normally.

Configuration

The command used to accept auto-complete is configured with accept_auto_completion.

accept_auto_completion          newline

You can attach it to another editor command instead, for example:

accept_auto_completion          tab
accept_auto_completion          move_caret_line_end

The setting refers to an editor command rather than a specific keyboard shortcut. Any keybinding that runs the selected command can therefore accept a visible suggestion, while retaining its normal behavior when no suggestion is available.

Auto-complete and AI completion

Koi's auto-complete and code completion solve slightly different problems.

Auto-complete finds text that already exists in the current document. It is fast, local, and does not require a model.

Code completion uses an AI model through Ollama to predict text that may not already exist. Both can be enabled at the same time, giving you quick document-based suggestions alongside generated code completion.

Why?

Not every completion needs a language model.

Names, identifiers, paths, terminology, and repeated phrases often already exist somewhere in the file you're editing. Koi makes those available as you type, including changes you haven't saved yet.