package tm-grammars

  1. Overview
  2. Docs
TextMate grammars as OCaml strings

Install

dune-project
 Dependency

Authors

Maintainers

Sources

tm-grammars-1.0.1.tbz
sha256=db846438528399b5e657ced04b004d56a5633b605039808c1fdb695a8d1bf4ed
sha512=6a83d6e79ef5a964f300942860373a583544f0e2cd9bb22e8fdfcaa12a0d834790b2da796873dbf334b7e448d7d8274a511c3b9224fc123a114de666db83fd53

doc/README.html

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

c, cpp, cram, css, diff, dockerfile, dune, go, graphql, html, java, javascript, json, jsonc, makefile, markdown, menhir, mlx, ocaml, ocamllex, opam, python, reason, ruby, rust, shellscript, sql, toml, tsx, typescript, yaml.

How to add a new grammar

  1. Add a new entry in sources.json with the language id and upstream source (repo, path, commit).
  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.