@codemirror/lang-yaml

YAML language support for the CodeMirror 6 code editor, with highlighting, indentation, folding, and frontmatter parsing.

Library
npm
v6.1.3
19 stars
MIT License

Repository Health

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

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
57 /100 Fair
Architecture 76
Code Quality 55
Innovation 62
Learning Curve 35

@codemirror/lang-yaml adds YAML language support to CodeMirror 6, the extensible in-browser code editor. It wraps the Lezer YAML grammar with CodeMirror’s language extension system, providing syntax highlighting, context-aware indentation for block sequences, mappings, and literal blocks, and code folding for flow collections and multi-line items.

Beyond plain YAML, the package exports a yamlFrontmatter helper that lets any other language (Markdown, JSON, etc.) be wrapped with an optional YAML frontmatter block delimited by triple-dash lines, using CodeMirror’s mixed-language parsing to parse the frontmatter as YAML and the rest of the document with the wrapped language.

What You Get

  • yaml() language extension - A single function that returns a LanguageSupport ready to drop into a CodeMirror extensions array.
  • Context-aware indentation - Custom indent rules for block sequences, block mappings, block literals, and flow collections so pressing Enter keeps YAML properly aligned.
  • Code folding support - Flow mappings/sequences and multi-line block items and literals can be folded via CodeMirror’s foldNodeProp integration.
  • yamlFrontmatter() composer - Wrap any other language (e.g. Markdown) with an optional YAML frontmatter block using CodeMirror’s mixed-language parsing.
  • Exported yamlLanguage - The underlying LRLanguage instance for advanced use cases like custom language data or further configuration.

Common Use Cases

  • Config file editors - Embedding a YAML editor for docker-compose, GitHub Actions, or Kubernetes manifests in a web-based IDE or admin tool.
  • Markdown editors with frontmatter - Using yamlFrontmatter to give a Markdown-based CMS or note-taking app correct highlighting for the YAML metadata block at the top of a document.
  • In-browser YAML linting/preview tools - Powering a YAML playground or validator that needs accurate parsing, folding, and indentation.
  • Static site generator dashboards - Editing YAML data files (e.g. Jekyll/Hugo data/config files) directly in a browser-based content tool.

Under The Hood

Architecture

The package is a thin, single-module wrapper (src/yaml.ts) around a Lezer-generated YAML parser, following the same shape as every other @codemirror/lang-* package: a compiled grammar supplies the parse tree, and the JS layer only attaches CodeMirror-specific behavior. It configures the imported Lezer YAML parser with an indentNodeProp that walks up the syntax tree from the cursor to compute indentation for BlockLiteral, BlockSequence, BlockMapping, and QuotedLiteral/Literal nodes, and a foldNodeProp for FlowMapping/FlowSequence and per-item folding of Item/Pair/BlockLiteral nodes. A second, independent language (frontmatterLanguage) is built from a hand-written Lezer grammar (src/frontmatter.grammar) that recognizes triple-dash delimiter lines, and yamlFrontmatter() composes it with any content language via Lezer’s parseMixed, dispatching FrontmatterContent to the YAML parser and Body to the wrapped language’s parser. There is little that could “break” architecturally since the design surface is two small, declarative language definitions rather than layered application logic.

Tech Stack

Written in TypeScript and built with @codemirror/buildhelper (a shared Rollup-based build tool used across the CodeMirror monorepo family), the package depends directly on @codemirror/autocomplete, @codemirror/language, @codemirror/state, and the @lezer/* parser runtime and highlighting packages. The frontmatter grammar is authored in Lezer’s own grammar DSL (frontmatter.grammar) and compiled to a parser table as part of the build, rather than hand-written token logic. No test runner, bundler config, or application framework ships in the published package itself; distribution is ESM/CJS dual output (dist/index.js and dist/index.cjs) with generated type declarations.

Code Quality

No test files or test directory are present in the repository, so there is no visible automated test coverage for the indentation, folding, or frontmatter-mixing logic. The code is fully typed TypeScript with consistent naming and API shape matching the rest of the @codemirror/lang-* family, and public exports carry /// doc comments that are extracted into the published README’s API reference. Error handling is minimal because the surface area is declarative configuration rather than runtime logic with failure modes; there’s no linter or CI configuration checked into this specific repo.

API Design The public API is extremely small and low-boilerplate: import yaml and call it inside an extensions array to get full YAML support, matching the zero-config convention shared by every @codemirror/lang-* package. Advanced consumers can reach yamlLanguage directly to extend language data or highlighting. The yamlFrontmatter(config) helper is a genuinely reusable composition primitive — it lets any other CodeMirror language be wrapped with optional YAML frontmatter in one call, which is more distinctive than the plain single-language wrappers most sibling lang-* packages provide.

Used by 16 apps in this directory

Go
40%
Apache 2.0

Rill

Analytics · Data Engineering

2,962

The fastest BI tool for humans and agents — define metrics, models, and dashboards as code and query them instantly on ClickHouse or DuckDB.

View details
88
Repo Health
88
Technical
64
Dependency
Built with
Go 40%
TypeScript 38%
Svelte 21%
Updated 6 days ago
TypeScript
67%
MIT

Scalar

Developer Tools

16,313

Beautiful, interactive OpenAPI documentation with a built-in offline-first API client and multi-language code generation — all in one open-source platform.

View details
90
Repo Health
89
Technical
65
Dependency
Built with
TypeScript 67%
Vue 29%
Updated 6 days ago
Python
79%
AGPL 3.0

Skyvern

AI Agents · Automation

23,257

Skyvern (YC S2023) automates browser-based workflows by pairing LLMs with computer vision, letting agents click, fill, and extract data on sites they've never seen, without brittle XPath selectors that break on every layout change.

View details
89
Repo Health
82
Technical
70
Dependency
Built with
Python 79%
TypeScript 19%
Updated 6 days ago
Python
100%
Other

Sourcebot

AI Code Assistants · Developer Tools · Search

4,005

A self-hosted, AI-powered code search engine that indexes every repo across GitHub, GitLab, Bitbucket, Gitea, Gerrit, and Azure DevOps, so both engineers and coding agents can search, browse, and ask questions about your codebase from one place.

View details
86
Repo Health
83
Technical
61
Dependency
Built with
Python 100%
Updated 1 weeks ago
TypeScript
85%
Apache 2.0

superset

AI Code Assistants · AI Development

15,503

Orchestrate an army of AI coding agents—Claude Code, Codex, Gemini CLI, and more—running simultaneously in isolated git worktrees from a single Electron desktop app.

View details
86
Repo Health
80
Technical
64
Dependency
Built with
TypeScript 85%
Updated 6 days ago
TypeScript
68%
AGPL 3.0

Tolaria

Note Taking

20,161

A free, open-source, local-first desktop app for managing markdown knowledge bases on macOS, Windows, and Linux — for second brains, company docs, or AI assistant memory and procedures.

View details
84
Repo Health
71
Technical
68
Dependency
Built with
TypeScript 68%
HTML 15%
Updated 6 days ago
Python
68%
AGPL 3.0

Tracecat

AI Agents · Automation · Security

3,860

Open-source agentic security automation platform that runs AI agents and durable workflows at scale with sandboxed execution.

View details
89
Repo Health
88
Technical
66
Dependency
Built with
Python 68%
TypeScript 30%
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