@codemirror/lang-java

Java language support for the CodeMirror 6 editor, powered by a Lezer grammar.

Library
npm
v6.0.2
16stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
23/100Needs Attention
Development Activity8
Maintenance0
Community12
Maturity60
Momentum12

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
56/100Fair
Architecture70
Code Quality55
Innovation40
Learning Curve60

@codemirror/lang-java is the official Java language plugin for CodeMirror 6, the extensible browser-based code editor. It wraps a Lezer grammar for Java into a ready-to-use CodeMirror language package, giving any editor built on CodeMirror instant syntax highlighting, code folding, and context-aware indentation for Java source files.

The package is intentionally small and focused: a single java() extension function returns a LanguageSupport object that can be dropped straight into a CodeMirror EditorView configuration alongside basicSetup. Under the hood it configures indentation rules for if/try/switch/labeled statements and blocks, plus fold behavior for classes, blocks, arrays, and block comments — the same conventions used by CodeMirror’s other bundled language packages, so it feels consistent with the rest of the ecosystem.

What You Get

  • A java() function returning a LanguageSupport extension ready to add to a CodeMirror EditorView
  • An exported javaLanguage LRLanguage instance for advanced configuration or language-data overrides
  • Indentation rules tuned for Java constructs — if/else, try/catch/finally, switch/case blocks, labeled statements, and braces
  • Code folding support for classes, methods, blocks, switch blocks, array initializers, and block comments
  • Comment-token metadata (// line comments, /* */ block comments) so CodeMirror’s comment-toggling commands work correctly

Common Use Cases

  • Adding Java syntax highlighting to an in-browser IDE or code playground built on CodeMirror 6
  • Building an online Java learning tool or coding-exercise platform with real-time editing feedback
  • Embedding a Java code viewer/editor in documentation sites or internal developer tools
  • Extending a multi-language code editor (e.g. a snippet manager or notebook UI) to support Java files

Under The Hood

Architecture The package is a thin, single-module wrapper: src/java.ts imports the pre-generated Lezer Java parser from @lezer/java and layers CodeMirror-specific node props onto it via LRLanguage.define. Indentation is expressed as a set of per-node-type rules (indentNodeProp.add) using CodeMirror’s continuedIndent, flatIndent, and delimitedIndent helpers, and folding is expressed the same way via foldNodeProp.add. The public surface is deliberately narrow — an exported javaLanguage LRLanguage and a java() factory returning a LanguageSupport — so the module has no internal layering to speak of; all the real parsing complexity lives upstream in the @lezer/java grammar package, and this package’s only job is gluing that grammar into CodeMirror’s language-support conventions.

Tech Stack Written in TypeScript and published as a dual ESM/CJS package (dist/index.js / dist/index.cjs) with generated .d.ts types. Its only runtime dependencies are @codemirror/language (for LRLanguage, LanguageSupport, and the indent/fold prop helpers) and @lezer/java (the actual grammar); @codemirror/buildhelper is a dev-only dependency used to build and test the package via cm-buildhelper and cm-runtests, the same tooling shared across all @codemirror/lang-* packages.

Code Quality No test files are present in this repository — testing is delegated to the shared cm-runtests tooling from @codemirror/buildhelper, which is standard practice across the CodeMirror language-package family rather than unique to this repo. The single source file is short, consistently typed, and uses doc comments (///) that are extracted into the generated README, but there is no local error-handling logic to assess since the module only declares configuration objects — it doesn’t run imperative logic that could fail at runtime.

What Makes It Unique The package itself is not novel — it follows the exact same LRLanguage/LanguageSupport pattern as every other @codemirror/lang-* package (lang-javascript, lang-python, etc.), which is precisely its value: consistency with the rest of the CodeMirror ecosystem rather than a bespoke design. Its only distinguishing content is the specific set of Java-aware indent and fold rules (switch/case depth handling, try/catch/finally continuation, labeled statements) tuned to Java’s grammar.

Used by 7 apps in this directory

Rust
67%
Other

GitButler

Developer Tools · Devops · AI Development

21,624

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
67
Dependency
Built with
Rust67%
TypeScript20%
Svelte11%
Updated yesterday
Python
51%
AGPL 3.0

LearnHouse

Learning Management · CMS

2,240

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
66
Dependency
Built with
Python51%
TypeScript48%
Updated yesterday
TypeScript
99%
Other

NocoBase

No Code Platforms · Low Code Platforms

24,071

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
TypeScript99%
Updated today
Go
61%
MIT

Obot

AI Agents

985

An open-source MCP platform for organizations — host MCP servers, run MCP registries, monitor usage, and build agents and chatbots on top of the Model Context Protocol from one self-hosted deployment.

View details
85
Repo Health
70
Technical
70
Dependency
Built with
Go61%
Svelte29%
Updated 3 days ago
Python
74%
AGPL 3.0

OpenViking

Databases · AI Development

35,793

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

View details
84
Repo Health
75
Technical
65
Dependency
Built with
Python74%
Rust14%
Updated yesterday
TypeScript
99%
Other

Sourcebot

Search · Developer Tools · AI Code Assistants

3,930

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
85
Repo Health
83
Technical
65
Dependency
Built with
TypeScript99%
Updated 2 days ago
TypeScript
92%
Apache 2.0

superset

AI Code Assistants · AI Development

13,825

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
85
Repo Health
80
Technical
67
Dependency
Built with
TypeScript92%
Updated today

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

Search