Skip to main content

setup-mlx

Install and configure mlx, the JSX syntax for OCaml, in a dune project. Use when the user asks to set up, enable, or add mlx or JSX to an OCaml project, when a .mlx file exists but dune-project has no mlx dialect, or when mlx-pp, ocamlmerlin-mlx, or ocamlformat-mlx is missing.

Source facts

Repository
davesnx/setup
Last source activity
September 7, 2026 at 20:22
Detected SKILL.md language
English
Stars
11
Forks
1

Install options

The review-first prompt is selected by default. You can switch to a direct command or download a local copy.

Review the source files

Read SKILL.md and any companion files shown by SkillsMP before deciding whether to install.

Showing SKILL.md

SKILL.md
Source instructions · Read-only preview
name
setup-mlx
description
Install and configure mlx, the JSX syntax for OCaml, in a dune project. Use when the user asks to set up, enable, or add mlx or JSX to an OCaml project, when a .mlx file exists but dune-project has no mlx dialect, or when mlx-pp, ocamlmerlin-mlx, or ocamlformat-mlx is missing.
# Setup mlx mlx adds JSX expressions to OCaml. Three tools take part: `mlx-pp` (package `mlx`), `ocamlmerlin-mlx` (Merlin reader, gives editors diagnostics and completion), and `ocamlformat-mlx` (formatter). To write mlx code, use the `mlx-syntax` skill. Work from the project root, the directory that holds `dune-project`. ## 1. Pick the package manager - `dune.lock/` exists, or `dune-workspace` contains `(pkg enabled)`: dune package management. - `_opam` exists, or confirm a switch is active with `opam switch show`: use opam. ## 2. Install the tools opam: ```sh opam install mlx ocamlmerlin-mlx ocamlformat-mlx ``` Dune package management: add `mlx`, `ocamlmerlin-mlx`, and `ocamlformat-mlx` to `(depends ...)` in the `(package ...)` stanza of `dune-project`, then run `dune pkg lock`. Dune's dev-tools list does not include these packages, so they must be regular dependencies. Done when `command -v mlx-pp ocamlmerlin-mlx ocamlformat-mlx` prints three paths (opam), or the lock solution lists all three packages (dune). ## 3. Declare the dialect Look for `(dialect` with `(name mlx)` in `dune-project`. If absent, append: ```lisp (dialect (name mlx) (implementation (extension mlx) (merlin_reader mlx) (format (run ocamlformat-mlx %{input-file})) (preprocess (run mlx-pp %{input-file})))) ``` `merlin_reader` needs `(lang dune 3.16)` or newer. If the project declares an older version, raise it and tell the user, because a lang bump can change other dune defaults. Keep `(merlin_reader mlx)` as written: Merlin resolves the name to the `ocamlmerlin-mlx` binary itself. Once declared, dune treats `.mlx` files as modules. `dune` files need no change. ## 4. Formatting `dune fmt` formats `.mlx` files through the `format` action above. `ocamlformat-mlx` skips every file with a warning when the project root has no `.ocamlformat`. If none exists, create one with `version = <output of ocamlformat --version>`. If one exists for plain `ocamlformat`, keep both binaries on the same base version: `version = 0.29.0` accepts `ocamlformat-mlx` `0.29.0.1`. ## 5. Check ocaml-lsp-server ```sh ocamllsp --version ``` Release 1.25.0 added `.mlx` support. If the version is lower or the binary is missing, run `opam install "ocaml-lsp-server>=1.25.0"` under opam, or `dune tools exec ocamllsp` under dune package management, which installs the current release. Editor plugins: VS Code OCaml Platform 2.0.0 or newer, `ocaml_mlx.nvim` for Neovim, `emacs-mlx` for Emacs. ## 6. Verify ```sh dune build dune ocaml merlin dump-config . | grep READER ``` Done when the build passes and every `.mlx` module shows `(READER (mlx))`. With no `.mlx` file in the project yet, the grep prints nothing; skip it. Report what was installed, the stanza added, any `lang dune` bump, and the `ocamllsp` version.
View on GitHub