@codemirror/autocomplete

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

Library
npm
v6.20.3
83 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
34 /100 Needs Attention
Development Activity 8
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
95%
MIT

Actual

Invoicing Finance

29,186

Local-first personal finance with envelope budgeting, end-to-end encryption, and multi-device sync — no subscription required.

View details
93
Repo Health
85
Technical
73
Dependency
Built with
TypeScript 95%
Updated 4 days ago
Python
67%
Apache 2.0

Agent Control

AI Agents

314

An open-source runtime control plane for AI agents — define safety guardrails once, apply them across agents built on LangChain, CrewAI, Google ADK, or AWS Strands, and update controls without redeploying code.

View details
74
Repo Health
71
Technical
67
Dependency
Built with
Python 67%
TypeScript 32%
Updated 4 days ago
Vue
43%
MIT

Alexandrie

Collaboration · Knowledge Management · Note Taking

2,777

The open-source, offline-first Notion, Obsidian & Confluence alternative with multi-tenant teams, OIDC/SSO, and one-command Docker deployment.

View details
86
Repo Health
73
Technical
74
Dependency
Built with
Vue 43%
TypeScript 41%
Go 13%
Updated 1 weeks ago
TypeScript
70%
Other

Budibase

Low Code Platforms · No Code Platforms

28,324

Build AI agents, automations, and internal apps on a single open-source platform with full self-hosting control.

View details
91
Repo Health
81
Technical
63
Dependency
Built with
TypeScript 70%
Svelte 26%
Updated 1 weeks ago
Go
64%
Apache 2.0

Coroot

Analytics · Monitoring

7,940

eBPF-powered observability with AI root cause analysis — zero code changes required, full-stack visibility out of the box.

View details
88
Repo Health
80
Technical
66
Dependency
Built with
Go 64%
Vue 34%
Updated 1 weeks ago
Ruby
61%
GPL 2.0

Discourse

Community

47,915

Open-source community platform with dynamic trust levels, real-time chat, and a powerful plugin architecture for self-hosted forums.

View details
89
Repo Health
89
Technical
67
Dependency
Built with
Ruby 61%
JavaScript 32%
Updated 4 days ago
TypeScript
98%
Other

Dokploy

Devops · Hosting Control Panel · Security

37,543

Self-hosted PaaS that deploys apps and databases on your own VPS using Docker, Traefik, and multi-build-system orchestration

View details
88
Repo Health
76
Technical
64
Dependency
Built with
TypeScript 98%
Updated 1 weeks ago
Java
34%
Apache 2.0

Enso

Analytics · Data Engineering · Low Code Platforms

7,441

A visual and textual programming platform for data prep and analysis where the node graph and the underlying Enso code are always perfectly in sync, built by an Alteryx co-founder on a GraalVM engine.

View details
59
Repo Health
90
Technical
61
Dependency
Built with
Java 34%
TypeScript 27%
Scala 26%
Updated 1 months ago
TypeScript
64%
Other

Epicenter

Developer Tools · Knowledge Management · Note Taking

4,808

A local-first monorepo led by Whispering, an open-source speech-to-text app, built on an MIT toolkit that turns your data into plain Markdown and SQLite files you own instead of a database you rent.

View details
88
Repo Health
90
Technical
64
Dependency
Built with
TypeScript 64%
HTML 13%
Svelte 13%
Updated 5 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