Emacs major mode for editing MLX files — OCaml with JSX syntax.
- Syntax highlighting for JSX tags, components, attributes, and delimiters
- Full OCaml highlighting via tuareg-mode
- JSX-aware indentation
- LSP support via eglot + ocamllsp
opam install mlx ocamlmerlin-mlx ocamlformat-mlx
Your dune-project must declare the MLX dialect with the merlin reader:
(dialect
(name mlx)
(implementation
(extension mlx)
(merlin_reader mlx)
(preprocess
(run mlx-pp %{input-file}))))In ~/.config/doom/packages.el:
(package! mlx-mode
:recipe (:host github :repo "ocaml-mlx/emacs-mlx"))In ~/.config/doom/config.el:
(use-package! mlx-mode
:mode "\\.mlx\\'"
:hook (mlx-mode . eglot-ensure))Then run doom sync and restart Emacs.
(use-package mlx-mode
:straight (:host github :repo "ocaml-mlx/emacs-mlx")
:mode "\\.mlx\\'"
:hook (mlx-mode . eglot-ensure))Clone this repository and add it to your load-path:
(add-to-list 'load-path "/path/to/emacs-mlx")
(require 'mlx-mode)
;; Auto-start eglot for .mlx files (optional)
(add-hook 'mlx-mode-hook #'eglot-ensure)If you use lsp-mode instead of eglot, just ensure ocamllsp is in your PATH and add:
(add-hook 'mlx-mode-hook #'lsp)mlx-mode automatically registers ocamllsp with both eglot and lsp-mode.
You only need to start your preferred LSP client, either via a hook (as shown above) or manually with M-x eglot / M-x lsp.
| Variable | Default | Description |
|---|---|---|
mlx-jsx-indent-offset |
2 |
Indentation for JSX children |
mlx-jsx-tag-face— lowercase tags (div,span)mlx-jsx-component-face— uppercase components (App,Module.View)mlx-jsx-attribute-face— attribute names (className,onClick)mlx-jsx-delimiter-face— delimiters (<,</,/>)
- mlx — the MLX preprocessor
- ocaml_mlx.nvim — Neovim plugin for MLX
- tree-sitter-mlx — Tree-sitter grammar for MLX
- tuareg — OCaml mode for Emacs
MIT