@codemirror/autocomplete

Autocompletion engine for the CodeMirror 6 code editor, with fuzzy matching, snippets, and bracket closing.

Library
npm
v6.20.4
83 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
33 /100 Needs Attention
Development Activity 4
Maintenance 0
Community 48
Maturity 60
Momentum 20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
78 /100 Good
Architecture 85
Code Quality 78
Innovation 82
Learning Curve 65

@codemirror/autocomplete is the official autocompletion package for CodeMirror 6, the in-browser code editor toolkit built by Marijn Haverbeke. It supplies the state, view, and tooltip logic needed to show a completion popup as users type, merging one or more registered completion sources into a single ranked list with fuzzy matching, sectioning, and configurable keybindings.

Beyond raw completion, the package ships snippet support (tab-through placeholder fields), automatic bracket and quote closing, and a small set of composable helpers (ifIn, ifNotIn, completeFromList) for scoping completion sources to specific syntax contexts. Language packages across the CodeMirror ecosystem — for JavaScript, Python, SQL, CSS, and more — depend on it to provide language-aware suggestions.

What You Get

  • An autocompletion() extension with configurable activation, keymap, and tooltip rendering
  • Fuzzy and strict matching engines that score and rank completions by relevance
  • A snippet system with tab-stop navigation and field editing
  • An automatic bracket and quote closing extension
  • Composable source helpers — completeFromList, ifIn, ifNotIn, completeAnyWord

Common Use Cases

  • Wiring language-aware code completion into a CodeMirror-based IDE or code playground
  • Providing word-based completion for plain-text or markdown editors
  • Building snippet-driven scaffolding for inserting boilerplate code
  • Adding bracket and quote auto-closing to any CodeMirror 6 editor instance

Under The Hood

Architecture — The package layers cleanly: state.ts owns the completionState StateField that tracks ActiveSource objects (one per completion source) through Inactive/Pending/Result transitions and rebuilds a CompletionDialog whenever a transaction requires it; tooltip.ts renders the popup via CodeMirror’s showTooltip facet; completion.ts defines the public Completion/CompletionContext/CompletionResult contracts and helpers like completeFromList, ifIn, ifNotIn, and insertCompletionText; filter.ts implements the FuzzyMatcher/StrictMatcher scoring engines consumed by state.ts’s sortOptions; snippet.ts and closebrackets.ts are self-contained sibling extensions composed into the top-level autocompletion() extension array in index.ts. Everything is threaded through CodeMirror’s Facet/StateField/StateEffect primitives rather than an autocomplete-specific event bus, so the package is really a set of pure reducers over EditorState/Transaction objects.

Tech Stack — Pure TypeScript (100% by GitHub’s language breakdown), compiled via the shared @codemirror/buildhelper devDependency into ESM (dist/index.js) and CJS (dist/index.cjs) builds with bundled .d.ts types. Runtime dependencies are exclusively sibling CodeMirror packages — @codemirror/state, @codemirror/view, @codemirror/language — plus @lezer/common for syntax-tree access, keeping the dependency graph entirely first-party with zero third-party runtime deps.

Code Quality — test/webtest-autocomplete.ts defines a purpose-built Runner class that spins up a real EditorView per test case and asserts against live completion state rather than mocking — a heavier-weight but higher-fidelity style of testing for editor behavior. Source files are consistently documented with /// doc comments consumed by CodeMirror’s own doc-generation tooling, naming is terse but consistent with the rest of the CodeMirror 6 codebase, and the code favors immutable value classes (ActiveSource, CompletionDialog, Option) updated via reducer-style .map()/.update() methods over mutation. No explicit try/catch is visible in the reviewed files; failures in async completion sources are expected to surface as rejected promises rather than being caught internally.

API Design — The public surface is small and deliberately composable: one extension factory (autocompletion(config)), a handful of pure helper functions (completeFromList, ifIn/ifNotIn, completeAnyWord) for building CompletionSource functions, and read-only accessors (completionStatus, currentCompletions, selectedCompletion) for host applications to introspect state. Wiring a working autocomplete requires only the autocompletion() extension plus a source via language data or the override config option. Every exported symbol carries a doc comment with cross-links, and the CompletionSource/CompletionResult contract cleanly separates synchronous simple cases (a fixed option list) from async/incremental ones (validFor, update, map) without forcing all consumers to deal with that complexity upfront.

Used by 54 apps in this directory

TypeScript
91%
Apache 2.0

HyperFrames

AI Design Tools · AI Development

70,938

Turn plain HTML and CSS into deterministic, pixel-perfect MP4 videos — authored by humans or AI agents, rendered by headless Chrome and FFmpeg.

View details
84
Repo Health
83
Technical
65
Dependency
Built with
TypeScript 91%
Updated 6 days ago
TypeScript
100%
Apache 2.0

ILLA Builder

Design Tools · Developer Tools · Low Code Platforms

12,333

Open-source low-code platform for building internal tools with drag-and-drop UI, reactive data bindings, and real-time collaboration.

View details
55
Repo Health
71
Technical
63
Dependency
Built with
TypeScript 100%
Updated 5 months ago
TypeScript
77%
Other

Joplin

Note Taking

56,853

The privacy-first, open-source note-taking app with end-to-end encrypted sync, AI assistance, and a powerful plugin ecosystem across every platform.

View details
93
Repo Health
87
Technical
60
Dependency
Built with
TypeScript 77%
JavaScript 14%
Updated 1 weeks ago
TypeScript
52%

Kener

Devops · Monitoring

5,216

Stunning, self-hosted status pages with real-time uptime monitoring, incident management, and multi-channel notifications in a single Docker container.

View details
87
Repo Health
76
Technical
66
Dependency
Built with
TypeScript 52%
Svelte 45%
Updated 1 weeks ago
TypeScript
63%
Apache 2.0

Laminar

AI Development · Monitoring

3,434

Open-source observability platform purpose-built for AI agents — trace, evaluate, debug, and monitor at scale with SQL access and real-time replay.

View details
86
Repo Health
76
Technical
65
Dependency
Built with
TypeScript 63%
Rust 35%
Updated 6 days ago
TypeScript
96%
Other

Langfuse

AI Development · Monitoring

36,276

Open source AI engineering platform for LLM observability, prompt management, evaluation, and debugging — self-host in minutes or use Langfuse Cloud.

View details
92
Repo Health
81
Technical
65
Dependency
Built with
TypeScript 96%
Updated 6 days ago
Python
53%
AGPL 3.0

LearnHouse

CMS · Learning Management

2,413

Open-source LMS with AI tutoring, real-time collaboration boards, live code execution, and built-in course monetization — self-hosted in minutes.

View details
90
Repo Health
77
Technical
65
Dependency
Built with
Python 53%
TypeScript 45%
Updated 6 days ago
JavaScript
42%
Other

LimeSurvey

Forms Surveys

3,778

The world's most flexible open-source survey platform with 900+ templates, conditional logic, 80+ languages, and full GDPR compliance for any scale.

View details
86
Repo Health
62
Technical
62
Dependency
Built with
JavaScript 42%
PHP 36%
CSS 12%
Updated 6 days ago
Python
62%
Apache 2.0

marimo

Data Engineering · Developer Tools

23,309

A reactive Python notebook that eliminates hidden state, runs reproducibly, and deploys as a web app or script — stored as pure Python, built for the AI era.

View details
90
Repo Health
91
Technical
65
Dependency
Built with
Python 62%
TypeScript 37%
Updated 6 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers