A modern, TreeSitter-powered, Emacs package for programming in OCaml
129
stars
335
commits
Emacs Lisp
primary language
Sep 7, 2026
updated
neocaml is a new Emacs package for programming in
OCaml. Built on
Tree-sitter, it provides major
modes for editing OCaml (.ml) and OCaml Interface (.mli) files with
font-locking, indentation, navigation, and toplevel (REPL) integration.
Beyond OCaml source code, neocaml also supports key parts of the OCaml
ecosystem: dune build files,
opam package definitions,
OCamllex lexer definitions (.mll),
Menhir parser definitions (.mly),
and cram test
files (.t), each with a dedicated major mode.
You can also view compiled OCaml artifacts (.cmi, .cmo, .cmx, etc.)
directly in Emacs via ocamlobjinfo.
It's also as cool as Neo from "The Matrix". ;-)
[!TIP] For detailed configuration, usage guides, and migration help, see the full documentation.
.ml and .mli filesbeginning-of-defun, end-of-defun, forward-sexp, sentence movement with M-a/M-e).ml and .mliff-find-other-file (C-c C-a)neocaml-repl), plus an alternative utop backend (neocaml-utop) that speaks utop's native protocol for precise error highlighting and completionfill-paragraph (M-q), comment continuation (M-j), and comment-dwim (M-;)neocaml-opam-mode) with font-lock, indentation, imenu, and opam lint integration (flymake and flycheck)neocaml-dune-mode) for dune, dune-project, and dune-workspace filesneocaml-dune-interaction-mode): build, test, clean, promote, fmt, exec (with watch mode via prefix arg)neocaml-ocamllex-mode) with font-lock, indentation, imenu, and OCaml language injection (Emacs 30+)neocaml-menhir-mode) with font-lock, indentation, imenu, and OCaml language injection (Emacs 30+)neocaml-cram-mode) with font-lock for commands, output, modifiers, and proseocaml and ocaml-interface tree-sitter grammars via M-x neocaml-install-grammarsM-x compile (errors, warnings, alerts, backtraces)_build directory awareness (offers to switch to source when opening build artifacts)neocaml is available on MELPA:
(use-package neocaml
:ensure t)
If the required tree-sitter grammars are not installed, run
M-x neocaml-install-grammars. Eglot is auto-configured - just run
M-x eglot in an OCaml buffer (requires
ocaml-lsp-server).
See the documentation for alternative installation methods and detailed configuration.
While neocaml is free software and will always be, the project would benefit from some funding. Consider supporting its ongoing development if you find it useful.
You can support the development of neocaml via:
Curious where neocaml is headed? See ROADMAP.md for ideas and planned improvements. Feedback and contributions on any of them are welcome.
See CONTRIBUTING.md for development setup, debugging, and how to run tests. Architecture and design notes live in doc/DESIGN.md.
Copyright (c) 2025-2026 Bozhidar Batsov and contributors.
Distributed under the GNU General Public License, version 3 or later. See LICENSE for details.
Emacs Lisp
98.2%
OCaml
1.5%
A modern, TreeSitter-powered, Emacs package for programming in OCaml
129
stars
335
commits
Emacs Lisp
primary language
Sep 7, 2026
updated
neocaml is a new Emacs package for programming in
OCaml. Built on
Tree-sitter, it provides major
modes for editing OCaml (.ml) and OCaml Interface (.mli) files with
font-locking, indentation, navigation, and toplevel (REPL) integration.
Beyond OCaml source code, neocaml also supports key parts of the OCaml
ecosystem: dune build files,
opam package definitions,
OCamllex lexer definitions (.mll),
Menhir parser definitions (.mly),
and cram test
files (.t), each with a dedicated major mode.
You can also view compiled OCaml artifacts (.cmi, .cmo, .cmx, etc.)
directly in Emacs via ocamlobjinfo.
It's also as cool as Neo from "The Matrix". ;-)
[!TIP] For detailed configuration, usage guides, and migration help, see the full documentation.
.ml and .mli filesbeginning-of-defun, end-of-defun, forward-sexp, sentence movement with M-a/M-e).ml and .mliff-find-other-file (C-c C-a)neocaml-repl), plus an alternative utop backend (neocaml-utop) that speaks utop's native protocol for precise error highlighting and completionfill-paragraph (M-q), comment continuation (M-j), and comment-dwim (M-;)neocaml-opam-mode) with font-lock, indentation, imenu, and opam lint integration (flymake and flycheck)neocaml-dune-mode) for dune, dune-project, and dune-workspace filesneocaml-dune-interaction-mode): build, test, clean, promote, fmt, exec (with watch mode via prefix arg)neocaml-ocamllex-mode) with font-lock, indentation, imenu, and OCaml language injection (Emacs 30+)neocaml-menhir-mode) with font-lock, indentation, imenu, and OCaml language injection (Emacs 30+)neocaml-cram-mode) with font-lock for commands, output, modifiers, and proseocaml and ocaml-interface tree-sitter grammars via M-x neocaml-install-grammarsM-x compile (errors, warnings, alerts, backtraces)_build directory awareness (offers to switch to source when opening build artifacts)neocaml is available on MELPA:
(use-package neocaml
:ensure t)
If the required tree-sitter grammars are not installed, run
M-x neocaml-install-grammars. Eglot is auto-configured - just run
M-x eglot in an OCaml buffer (requires
ocaml-lsp-server).
See the documentation for alternative installation methods and detailed configuration.
While neocaml is free software and will always be, the project would benefit from some funding. Consider supporting its ongoing development if you find it useful.
You can support the development of neocaml via:
Curious where neocaml is headed? See ROADMAP.md for ideas and planned improvements. Feedback and contributions on any of them are welcome.
See CONTRIBUTING.md for development setup, debugging, and how to run tests. Architecture and design notes live in doc/DESIGN.md.
Copyright (c) 2025-2026 Bozhidar Batsov and contributors.
Distributed under the GNU General Public License, version 3 or later. See LICENSE for details.
Emacs Lisp
98.2%
OCaml
1.5%