Languages, Linters & Themes
Languages
Install a language package and pass its LanguageSupport object to lang:
Official language packages include:
@codemirror/lang-angular, lang-cpp, lang-css, lang-html, lang-java, lang-javascript, lang-json, lang-lezer, lang-markdown, lang-php, lang-python, lang-rust, lang-sql, lang-vue, lang-wast, lang-xml
Many community packages are also available. See the CodeMirror language list and the list below.
Community language packages
@phoenix-plugin-registry/petetnt.brackets-codemirror-fortran@phoenix-plugin-registry/petetnt.brackets-codemirror-go@acarl005/lang-sql@ark-us/codemirror-lang-taylor@formulavize/lang-fiz@gravitywiz/codemirror-lang-gfcalc@nextjournal/lang-clojure@plutojl/lang-julia@polybase/codemirror-lang-javascript@replit/codemirror-lang-nix@replit/codemirror-lang-csharp@replit/codemirror-lang-solidity@replit/codemirror-lang-svelte@zhijiu/lang-sqlcodemirror-lang-boolcodemirror-lang-brainfuckcodemirror-lang-cherrycodemirror-lang-chordprocodemirror-lang-circomcodemirror-lang-edncodemirror-lang-ejscodemirror-lang-fslcodemirror-lang-gmlcodemirror-lang-golfscriptcodemirror-lang-homescriptcodemirror-lang-html-n8ncodemirror-lang-inform7codemirror-lang-jcodemirror-lang-janetcodemirror-lang-kcodemirror-lang-karolcodemirror-lang-mermaidcodemirror-lang-n8n-expressioncodemirror-lang-prologcodemirror-lang-qpencodemirror-lang-qtamcodemirror-lang-rcodemirror-lang-rome-astcodemirror-lang-romecodemirror-lang-rushcodemirror-lang-scopescriptcodemirror-lang-statementgcode-lang-codemirrorgmail-langlang-bqnlang-clojurelang-dlang-feellang-firestore
Linters
Pass a LintSource to linter. Add gutter to show a marker on lines with problems.
For JavaScript, @codemirror/lang-javascript provides esLint(), which can be combined with eslint-linter-browserify:
The number of diagnostics is available as diagnosticCount on the instance, and lint() runs the linter on demand.
In the editor, Ctrl+Shift+M (Cmd+Shift+M on macOS) opens the lint panel and F8 jumps to the next diagnostic.
Themes and dark mode
darktells CodeMirror that the editor has a dark background, so built-in UI such as the selection and panels use dark colors.themeaccepts a style spec object passed toEditorView.theme.
Ready-made themes are usually distributed as extensions. Add them through extensions:
Examples: @codemirror/theme-one-dark, @uiw/codemirror-themes, codemirror6-bootstrap-theme.
Other extensions
Any CodeMirror Extension can be passed through extensions. They are combined with the extensions generated from the other props.
lang and linter could also be passed through extensions. They are separate props for type safety and for compatibility with earlier versions.
When props change, the component reconfigures the editor automatically. If you change something the component cannot detect, call forceReconfigure() on the instance.