Skip to content
Talk to an engineerRequest access

Languages

Every language val_highlight highlights, with its import, its names and aliases, and the files it is found by.

55 languages, plus the generic fallback and plain text: the 57 grammars in allLanguages. Import one from package:val_highlight/languages/<file>, or all of them from languages/all.dart.

Language Import Grammar Names Files
Bash and POSIX shell scripts. bash.dart bashLanguage bash, sh, shell, zsh, console .sh, .bash, .zsh
Windows batch files (.bat, .cmd). batch.dart batchLanguage batch, bat, cmd, dos .bat, .cmd
C. c.dart cLanguage c, h .c, .h
Clojure, ClojureScript and EDN. clojure.dart clojureLanguage clojure, clj, cljs, cljc, edn .clj, .cljs, .cljc, .edn
CMake. cmake.dart cmakeLanguage cmake, cmakelists .cmake, CMakeLists.txt
C++ (C++23). cpp.dart cppLanguage cpp, c++, cxx, hpp, cc, hh .cpp, .cc, .cxx, .hpp, .hh, .hxx, .ipp, .ixx
C# (12+). csharp.dart csharpLanguage csharp, cs, c# .cs, .csx
CSS, including nesting and custom properties. css.dart cssLanguage css .css
Dart. dart.dart dartLanguage dart .dart
Unified and git diffs. diff.dart diffLanguage diff, patch .diff, .patch
Dockerfile (and Containerfile). dockerfile.dart dockerfileLanguage dockerfile, docker, containerfile .dockerfile, Dockerfile, Containerfile
Elixir. elixir.dart elixirLanguage elixir, ex, exs .ex, .exs, .heex, mix.lock
Erlang. erlang.dart erlangLanguage erlang, erl .erl, .hrl, .escript, rebar.config
F#. fsharp.dart fsharpLanguage fsharp, fs, f# .fs, .fsi, .fsx
A language-neutral grammar for code whose language is unknown. generic.dart genericLanguage generic —
Go. go.dart goLanguage go, golang .go
GraphQL queries and schema definitions. graphql.dart graphqlLanguage graphql, gql .graphql, .gql, .graphqls
Groovy, including Gradle build scripts (build.gradle). groovy.dart groovyLanguage groovy, gradle .groovy, .gradle, .gvy, .gy, .gsh, Jenkinsfile
Haskell. haskell.dart haskellLanguage haskell, hs .hs, .lhs
HCL, including Terraform and OpenTofu configuration. hcl.dart hclLanguage hcl, terraform, tf, opentofu .tf, .tfvars, .hcl
HTML, with embedded CSS in <style> and JavaScript in <script>. html.dart htmlLanguage html, htm, xhtml, vue, svelte .html, .htm, .xhtml, .vue, .svelte
INI files and Java .properties files. ini.dart iniLanguage ini, properties, conf, cfg, editorconfig, gitconfig .ini, .cfg, .conf, .properties, .editorconfig, .gitconfig, gradle.properties
Java (21+), including records, sealed types and text blocks. java.dart javaLanguage java, jsp .java
JavaScript, including JSX-free modern syntax. javascript.dart javascriptLanguage javascript, js, mjs, cjs .js, .mjs, .cjs
JSON, including the comments allowed by JSONC. json.dart jsonLanguage json, jsonc .json, .jsonc
JavaScript with JSX elements, as used by React. jsx.dart jsxLanguage jsx, react .jsx
Julia. julia.dart juliaLanguage julia, jl .jl
Kotlin, including Kotlin script (.kts, such as build.gradle.kts). kotlin.dart kotlinLanguage kotlin, kt, kts .kt, .kts
LaTeX and TeX. latex.dart latexLanguage latex, tex .tex, .sty, .cls, .ltx, .bib
Less. less.dart lessLanguage less .less
Lua 5.4, including Luau-style usage in game and editor scripts. lua.dart luaLanguage lua, luau .lua, .luau, .rockspec
Make (GNU make syntax). makefile.dart makefileLanguage makefile, make, mk, mak .mk, .mak, Makefile, GNUmakefile
Markdown (CommonMark plus GitHub extensions). markdown.dart markdownLanguage markdown, md, mkdown, mkd .md, .markdown, .mkd
x86 assembly in NASM/YASM syntax. nasm.dart nasmLanguage nasm, asm, x86asm, assembly .asm, .nasm, .s
nginx configuration. nginx.dart nginxLanguage nginx, nginxconf nginx.conf
Objective-C and Objective-C++. objectivec.dart objectiveCLanguage objectivec, objc, objective-c, obj-c, objectivecpp, objc++ .m, .mm
OCaml. ocaml.dart ocamlLanguage ocaml, ml .ml, .mli
Perl 5. perl.dart perlLanguage perl, pl, pm .pl, .pm, .t, .psgi
PHP 8. php.dart phpLanguage php, php8, phtml .php, .phtml, .php8, .php7
Plain text: no highlighting. plaintext.dart plainTextLanguage plaintext, text, txt, plain .txt
PowerShell. powershell.dart powershellLanguage powershell, ps1, pwsh, ps, posh .ps1, .psm1, .psd1
Protocol Buffers (proto2, proto3 and editions). protobuf.dart protobufLanguage protobuf, proto .proto
Python 3. python.dart pythonLanguage python, py, py3, gyp .py, .pyw, .pyi
R. r.dart rLanguage r, rscript, splus .r, .rprofile
Ruby, including Gemfiles, Podfiles, Rakefiles and Fastlane files. ruby.dart rubyLanguage ruby, rb, jruby, podfile, gemfile .rb, .rake, .gemspec, .podspec, .ru, .rbw, .thor, Gemfile, Rakefile, Podfile, Fastfile, Brewfile, Appfile, Matchfile, Pluginfile, Vagrantfile, Guardfile, Dangerfile, Berksfile, Capfile
Rust. rust.dart rustLanguage rust, rs .rs
Scala 2 and 3. scala.dart scalaLanguage scala, sc .scala, .sc, .sbt
Sass in SCSS syntax. scss.dart scssLanguage scss, sass .scss
Solidity. solidity.dart solidityLanguage solidity, sol .sol
SQL, covering the common ANSI syntax plus popular dialect keywords. sql.dart sqlLanguage sql, postgresql, postgres, mysql, sqlite, plsql, tsql .sql
Swift (6), including raw strings, macros and result builders. swift.dart swiftLanguage swift .swift
TOML. toml.dart tomlLanguage toml .toml, Cargo.lock, Pipfile, poetry.lock
TypeScript with JSX elements, as used by React. tsx.dart tsxLanguage tsx .tsx
TypeScript. typescript.dart typescriptLanguage typescript, ts, mts, cts .ts, .mts, .cts
XML, including SVG, plist and similar formats. xml.dart xmlLanguage xml, svg, plist, xsd, xsl, rss, atom .xml, .svg, .plist, .xsd, .xsl, .xslt, .rss
YAML. yaml.dart yamlLanguage yaml, yml .yaml, .yml
Zig. zig.dart zigLanguage zig .zig, .zon
dockerfileLanguage: more

Each instruction is a region that runs to the end of its logical line, following \ continuations. Heredocs (RUN <<EOF … EOF) are strings.

genericLanguage: more

It highlights what most programming, scripting and configuration languages share: //, /* */ and # comments, quoted strings, numbers, a broad set of common keywords and literals, types, function calls, annotations and operators. It is the fallback of allLanguagesRegistry() and of CodeView when no language is given.

markdownLanguage: more

Fenced code blocks are highlighted in the language named after the fence (```dart) when that language is in the Highlighter’s registry; otherwise their content is scoped as Scopes.code.

phpLanguage: more

Code is PHP by default, so snippets without <?php highlight correctly. ?> switches to HTML until the next <?php or <?=, and a file that starts with markup is HTML until its first PHP tag.

plainTextLanguage: more

Plain text: no highlighting. Highlighting with it is nearly free, so it is used for placeholders and for code in an unknown language.

powershellLanguage: more

PowerShell. Keywords and operators are case-insensitive.

Names are what a registry looks up — in a Markdown code fence, with highlightByName, or with LanguageRegistry.lookup — ignoring case. Files are the extensions and whole file names that LanguageRegistry.forFileName and LanguageDetector match; a whole name wins over an extension. This table is generated from allLanguages, so it lists exactly what the package ships.

Each language is its own library of one const grammar:

import 'package:val_highlight/languages/kotlin.dart'; // kotlinLanguage
import 'package:val_highlight/languages/python.dart'; // pythonLanguage

A language library exports only its grammar; import package:val_highlight/val_highlight.dart (or val_highlight_flutter) as well for Highlighter and the rest. languages/all.dart imports every language, with the list allLanguages and the registry allLanguagesRegistry() — convenient, but your app then includes every grammar.

  • genericLanguage highlights code in a language val_highlight doesn’t know: //, /* */ and # comments, quoted strings, numbers, a broad set of common keywords and literals, types, function calls, annotations and operators. It is the fallback of allLanguagesRegistry() and of CodeView.
  • plainTextLanguage highlights nothing, at almost no cost.

Language detection never picks either of them.

HTML highlights <style> as CSS and <script> as JavaScript. Markdown highlights each fenced block in the language its fence names, when it is given a registry — see languages inside languages.

Change a built-in language from your own app — add keywords, put your own rules first — with changing a language, or write a new one from building blocks with writing a grammar. To add a language to the package itself, see CONTRIBUTING.md.