@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 →
25 /100 Needs Attention
Development Activity 8
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
55%
Other

authentik

Authentication · Security

25,511

The self-hosted Identity Provider that replaces Okta, Auth0, and Entra ID with a unified SSO platform supporting SAML, OAuth2/OIDC, LDAP, RADIUS, and WebAuthn.

View details
92
Repo Health
81
Technical
66
Dependency
Built with
Python 55%
TypeScript 35%
Updated 1 weeks ago
Python
64%
MIT

Flowfile

Data Engineering

353

Visual ETL that compiles to Polars — build pipelines on a canvas, export as standalone Python, and run anywhere without platform lock-in.

View details
83
Repo Health
81
Technical
66
Dependency
Built with
Python 64%
Vue 18%
TypeScript 16%
Updated 1 weeks ago
TypeScript
62%
Other

Flowise

AI Development · Automation · Developer Tools

55,459

Drag-and-drop visual builder for AI agents, RAG pipelines, and multi-agent systems—deploy anywhere in minutes.

View details
86
Repo Health
77
Technical
63
Dependency
Built with
TypeScript 62%
JavaScript 27%
Updated 1 months ago
Rust
65%
Other

GitButler

AI Development · Developer Tools · Devops

21,660

Git, but better — a modern version control client with stacked branches, parallel workflows, unlimited undo, and first-class support for AI-powered development.

View details
89
Repo Health
84
Technical
66
Dependency
Built with
Rust 65%
TypeScript 21%
Svelte 11%
Updated 1 weeks ago
TypeScript
93%
Apache 2.0

InsForge

Databases · Developer Tools

12,979

The all-in-one, open-source backend platform purpose-built for AI coding agents — giving your agent database, auth, storage, edge functions, a model gateway, and compute to ship full-stack apps end-to-end.

View details
86
Repo Health
81
Technical
72
Dependency
Built with
TypeScript 93%
Updated 1 weeks ago
TypeScript
64%
Apache 2.0

Laminar

AI Development · Monitoring

3,255

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
85
Repo Health
76
Technical
66
Dependency
Built with
TypeScript 64%
Rust 34%
Updated 1 weeks ago
TypeScript
98%
Other

Langfuse

AI Development · Monitoring

34,609

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 98%
Updated 1 weeks ago
Python
51%
AGPL 3.0

LearnHouse

CMS · Learning Management

2,265

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

View details
89
Repo Health
77
Technical
66
Dependency
Built with
Python 51%
TypeScript 47%
Updated 1 weeks ago
Python
61%
Apache 2.0

marimo

Data Engineering · Developer Tools

22,765

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 61%
TypeScript 37%
Updated 1 weeks 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