mirror of
https://github.com/doomemacs/doomemacs.git
synced 2025-12-06 02:30:33 -08:00
4.8 KiB
4.8 KiB
lang/ocaml
Table of Contents TOC
Description
This module adds OCaml support to Doom Emacs, powered by tuareg-mode.
- Code completion, documentation look-up, code navigation and refactoring (merlin)
- Type, documentation and function argument display on idle (merlin-eldoc)
- REPL (utop)
- Syntax-checking (
merlinwith flycheck-ocaml) - Auto-indentation (ocp-indent)
- Code formatting (ocamlformat)
- Dune file format (dune)
Module Flags
This module provides no flags.
Plugins
Prerequisites
This module has no hard dependencies, but it is recommanded that you install opam and the following opam (optional) packages:
opam install merlin utop ocp-indent dune ocamlformat
Features
- The following files should have syntax highlighting support:
.ml{i,p,y,},.eliom{i,},jbuild,dune,opam merlin-modeis activated whenever a.merlinfile is found (including in a parent directory) andocamlmerlinexecutable is present- Line-based auto-indentation is provided by
ocp-indent, if it is available.
Configuration
- If
:completion companyis enabled then autocomplete is provided bymerlin - When
:checkers syntaxis enabled thenflycheck-ocamlis activated to do on-the-fly syntax/type checking viamerlin, otherwise this is only done when the file is saved. - Spell checking is activated in comments if
:checkers spellis active - A REPL is provided if
utopis installed and:tools evalis active - If
:editor formatis enabled, theocamlformatexecutable is available and there is an.ocamlformatfile present thenformat-all-bufferis bound toocamlformat, otherwise toocp-indent - If
:editor multiple-cursorsis enabled then identifiers can be refactored withv Rand multiple cursors (this correctly matches identifier occurrences according to scope, it is not purely a textual match) - If
:emacs imenuis enabled then top level symbols (modules, type, functions, etc.) can be looked up usingSPC / i
Run doom sync to install all packages and doom doctor to diagnose missing
tools.
Appendix
Commands
| Command | Key | Description |
|---|---|---|
merlin-type-enclosing |
<localleader> t |
display type under point |
tuareg-find-alternate-file |
<localleader> a |
switch between .ml and .mli |
merlin-locate |
g d |
lookup definition |
merlin-occurences |
SPC c D |
lookup references |
merlin-document |
K |
lookup documentation |
merlin-imenu |
SPC s i |
symbol lookup in file |
merlin-iedit-occurrences |
v R |
visual refactor identifier under point (multiple cursors) |
utop |
SPC o r |
open utop as REPL |
utop-eval-region |
SPC c e |
evaluate selected region in utop |
Hacks
set-ligatures!is called with the full tuareg prettify symbol list, this can cause columns to change as certain keywords are shortened (e.g.funbecomes λ.tuareg-opam-update-envis called the first timetuaregis loaded