Skip to content

Latest commit

 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mlx-mode

Emacs major mode for editing MLX files — OCaml with JSX syntax.

Features

  • Syntax highlighting for JSX tags, components, attributes, and delimiters
  • Full OCaml highlighting via tuareg-mode
  • JSX-aware indentation
  • LSP support via eglot + ocamllsp

Prerequisites

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}))))

Installation

Doom Emacs

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 (straight.el)

(use-package mlx-mode
  :straight (:host github :repo "ocaml-mlx/emacs-mlx")
  :mode "\\.mlx\\'"
  :hook (mlx-mode . eglot-ensure))

Manual

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)

lsp-mode (alternative to eglot)

If you use lsp-mode instead of eglot, just ensure ocamllsp is in your PATH and add:

(add-hook 'mlx-mode-hook #'lsp)

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.

Customization

Variable Default Description
mlx-jsx-indent-offset 2 Indentation for JSX children

Faces

  • 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 (<, </, />)

Related projects

License

MIT

About

mlx-mode for Emacs (JSX in Ocaml)

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages