@codemirror/lang-python

Python language support for the CodeMirror code editor, with highlighting, indentation, and autocompletion.

Library
npm
v6.2.1
42 stars
MIT License

Repository Health

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

Technical Analysis

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

@codemirror/lang-python adds first-class Python editing to CodeMirror 6. It wraps the Lezer Python parser in a CodeMirror LanguageSupport, layering on syntax highlighting, context-aware indentation for blocks and continuation lines, code folding, and completion sources for both built-in globals and locally defined names.

Dropping the python() extension into an EditorView gives you a Python-aware editing surface without hand-rolling tokenizers or indentation heuristics. It is one of the official CodeMirror language packages, sharing the same architecture and release conventions as the rest of the ecosystem.

What You Get

  • A ready-to-use python() LanguageSupport extension for CodeMirror 6.
  • Syntax highlighting driven by the Lezer Python grammar.
  • Context-aware indentation for blocks, brackets, and continuation lines, including match/case, else/elif, and except handling.
  • Autocompletion for Python built-in globals, keywords, and locally defined names.
  • Code folding for functions, classes, collections, and multiline strings.

Common Use Cases

  • Building an in-browser Python code editor or REPL front-end.
  • Adding a Python editing mode to a documentation site, notebook, or teaching tool.
  • Powering code cells in a low-code or data-science web application.

Under The Hood

Architecture — The package is a thin, well-factored integration layer over the Lezer Python parser. src/python.ts defines pythonLanguage as an LRLanguage that configures the imported Lezer parser with indentNodeProp and foldNodeProp metadata; helper functions innerBody and indentBody walk the syntax tree to resolve Python’s whitespace-significant indentation, handling block bodies, match/case, and deindenting keywords. The exported python() factory returns a LanguageSupport bundling the language with two autocomplete data providers wired from src/complete.ts.

Tech Stack — Written entirely in TypeScript (100% of the source), it depends on @lezer/python and @lezer/common for parsing plus @codemirror/language, @codemirror/autocomplete, and @codemirror/state for editor integration. It builds to dual ESM/CJS output via the @codemirror/buildhelper toolchain (cm-buildhelper), ships type definitions, and is marked sideEffects: false for tree-shaking.

Code Quality — The codebase is compact (~12KB of source across python.ts and complete.ts) and idiomatic for the CodeMirror ecosystem, using a NodeWeakMap cache and a declarative gatherCompletions table keyed by node type to collect scoped definitions. Public APIs carry doc comments. Testing is present via a test-indent.ts suite run with cm-runtests, focused on the indentation logic that is the trickiest part of the package.

API Design — The public surface is minimal and ergonomic: importing python() and adding it to an editor’s extensions is the entire happy path, matching the uniform convention shared across all official CodeMirror language packages. Lower-level exports (pythonLanguage, globalCompletion, localCompletionSource) let advanced users compose custom behavior. The README documents each export with linked type references, keeping boilerplate near zero.

Used by 26 apps in this directory

Python
45%
GPL 3.0

MaxKB

AI Development · Knowledge Management

23,022

Build enterprise-grade AI agents with RAG, workflows & multi-modal support

View details
92
Repo Health
68
Technical
66
Dependency
Built with
Python 45%
Vue 37%
TypeScript 17%
Updated 2 days ago
Clojure
57%
Other

Metabase

Analytics

49,827

The open-source BI platform that lets anyone ask questions and build dashboards without writing SQL — with an embedded analytics SDK and AI-powered query assistant included.

View details
95
Repo Health
84
Technical
62
Dependency
Built with
Clojure 57%
TypeScript 38%
Updated yesterday
TypeScript
92%
Other

n8n

Automation · No Code Platforms

208,437

Code when you need it, UI when you don't — the workflow automation platform built for technical teams who refuse to choose.

View details
95
Repo Health
87
Technical
62
Dependency
Built with
TypeScript 92%
Updated 2 days ago
TypeScript
99%
Other

NocoBase

Low Code Platforms · No Code Platforms

24,686

Open-source AI + no-code platform that lets coding agents and people collaborate to build business systems fast on proven infrastructure.

View details
94
Repo Health
81
Technical
63
Dependency
Built with
TypeScript 99%
Updated yesterday
TypeScript
97%
GPL 3.0

OpenKnowledge

Code Editors · Knowledge Management · Note Taking

4,674

A beautiful, local-first markdown IDE that turns any git repo into a live collaborative workspace for humans and AI coding agents like Claude, Codex, and OpenCode.

View details
80
Repo Health
89
Technical
64
Dependency
Built with
TypeScript 97%
Updated yesterday
Python
38%
Other

Open WebUI

AI Agents · AI Assistants

156,607

The extensible, privacy-first AI platform that runs Ollama, OpenAI, and any LLM backend behind a polished, feature-packed web interface.

View details
92
Repo Health
75
Technical
66
Dependency
Built with
Python 38%
Svelte 35%
JavaScript 19%
Updated yesterday
Python
73%
AGPL 3.0

OpenViking

AI Development · AI Memory · Databases

40,705

An open-source context database that gives AI agents a unified filesystem for memory, resources, and skills with hierarchical tiered retrieval.

View details
85
Repo Health
75
Technical
64
Dependency
Built with
Python 73%
TypeScript 12%
Rust 11%
Updated yesterday
JavaScript
64%
AGPL 3.0

overleaf

Collaboration · Productivity

18,266

Open-source, real-time collaborative LaTeX editor with sandboxed compilation and full TeXLive support for self-hosted academic and research teams.

View details
84
Repo Health
80
Technical
59
Dependency
Built with
JavaScript 64%
TypeScript 30%
Updated 1 months ago
Python
49%
Other

Arize Phoenix

Analytics · Devops · Monitoring

11,976

Open-source AI observability platform for tracing, evaluating, and debugging LLM applications with built-in intelligence and MCP support.

View details
92
Repo Health
88
Technical
67
Dependency
Built with
Python 49%
TypeScript 43%
Updated yesterday

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