TextMate grammars as opam packages
  • Standard ML 60.1%
  • OCaml 39.8%
Find a file
2026-04-15 09:08:29 +00:00
.github/workflows Update davesnx/dune-release-action to v0.3.0 2026-04-13 18:49:31 +00:00
packages REmove tm-grammar- prefix from folders 2026-04-15 09:08:29 +00:00
scripts REmove tm-grammar- prefix from folders 2026-04-15 09:08:29 +00:00
test Add tests 2026-04-13 14:47:21 +00:00
vendor Add all shiki grammars 2026-03-16 20:38:54 +00:00
.gitattributes add gitattributes for lf in win 2026-02-27 13:54:26 +00:00
.gitignore Initial commit: 34 TextMate grammar packages + tm-grammars-all meta-package 2026-02-25 19:31:33 +00:00
CHANGES.md Prepare 2.0.0 2026-04-13 16:58:18 +00:00
dune REmove tm-grammar- prefix from folders 2026-04-15 09:08:29 +00:00
dune-project join all packages as a sublibs 2026-02-28 18:55:43 +00:00
LICENSE cleanup readme 2026-02-26 16:06:04 +00:00
Makefile REmove tm-grammar- prefix from folders 2026-04-15 09:08:29 +00:00
README.md Add all shiki grammars 2026-03-16 20:38:54 +00:00
README.mld Add all shiki grammars 2026-03-16 20:38:54 +00:00
sources.json Add all shiki grammars 2026-03-16 20:38:54 +00:00
THIRD-PARTY-LICENSES Add all shiki grammars 2026-03-16 20:38:54 +00:00
tm-grammars.opam Remove x-ci-accept-failure 2026-03-09 17:28:09 +00:00

tm-grammars

OCaml package that exposes TextMate grammars as JSON strings. Each language is available as a library ([tm-grammars.ocaml], [tm-grammars.tsx], etc.) so downstream users only link what they need.

Install

opam install tm-grammars -y

Usage

(libraries tm-grammars)
let grammar_ocaml = Tm_grammars.ocaml
let grammar_tsx = Tm_grammars.tsx

You can also list grammars dynamically:

let all = Tm_grammars.all          (* (string * string) list *)
let ids = Tm_grammars.available    (* string list *)

Use a single grammar

Depend on a sublibrary to pull in only the grammar you need.

(libraries tm-grammars.ocaml tm-grammars.tsx)
let grammar_ocaml = Tm_grammar_ocaml.json
let grammar_tsx = Tm_grammar_tsx.json

Supported language ids

abap, actionscript-3, ada, angular-expression, angular-html, angular-inline-style, angular-inline-template, angular-let-declaration, angular-template, angular-template-blocks, angular-ts, apache, apex, apl, applescript, ara, asciidoc, asm, astro, awk, ballerina, bat, beancount, berry, bibtex, bicep, bird2, blade, bsl, c, c3, cadence, cairo, clarity, clojure, cmake, cobol, codeowners, codeql, coffee, common-lisp, coq, cpp, cpp-macro, cram, crystal, csharp, css, csv, cue, cypher, d, dart, dax, desktop, diff, dockerfile, dotenv, dream-maker, dune, edge, elixir, elm, emacs-lisp, erb, erlang, es-tag-css, es-tag-glsl, es-tag-html, es-tag-sql, es-tag-xml, fennel, fish, fluent, fortran-fixed-form, fortran-free-form, fsharp, gdresource, gdscript, gdshader, genie, gherkin, git-commit, git-rebase, gleam, glimmer-js, glimmer-ts, glsl, gn, gnuplot, go, graphql, groovy, hack, haml, handlebars, haskell, haxe, hcl, hjson, hlsl, html, html-derivative, http, hurl, hxml, hy, imba, ini, java, javascript, jinja, jinja-html, jison, json, json5, jsonc, jsonl, jsonnet, jssm, jsx, julia, just, kdl, kotlin, kusto, latex, lean, less, liquid, llvm, log, logo, lua, luau, makefile, markdown, markdown-nix, markdown-vue, marko, matlab, mdc, mdx, menhir, mermaid, mipsasm, mlx, mojo, moonbit, move, narrat, nextflow, nextflow-groovy, nginx, nim, nix, nushell, objective-c, objective-cpp, ocaml, ocamllex, odin, opam, openscad, pascal, perl, php, pkl, plsql, po, polar, postcss, powerquery, powershell, prisma, prolog, proto, pug, puppet, purescript, python, qml, qmldir, qss, r, racket, raku, razor, reason, reg, regexp, rel, riscv, ron, rosmsg, rst, ruby, rust, sas, sass, scala, scheme, scss, sdbl, shaderlab, shellscript, shellsession, smalltalk, solidity, soy, sparql, splunk, sql, ssh-config, stata, stylus, surrealql, svelte, swift, system-verilog, systemd, talonscript, tasl, tcl, templ, terraform, tex, toml, ts-tags, tsv, tsx, turtle, twig, typescript, typespec, typst, v, vala, vb, verilog, vhdl, viml, vue, vue-directives, vue-html, vue-interpolations, vue-sfc-style-variable-injection, vue-vine, vyper, wasm, wenyan, wgsl, wikitext, wit, wolfram, xml, xsl, yaml, zenscript, zig.

How to add a new grammar

  1. Add a new entry in sources.json with the language id, upstream source (repo, path, commit), and license metadata (license, optional licenseUrl, optional originalSource).
  2. Run make sync to download the grammar into vendor/<language-id>.json.
  3. Run make generate to regenerate packages and metadata.
  4. Run make build (and optionally make test) to verify everything still builds.

License

MIT. See LICENSE.