doomemacs/modules/lang/ocaml
Rudi Grinberg bdeb02ddc2 Fix tuareg-find-alternate-file binding
This binding should be available whenever tuareg is loaded. Previously,
it would loaded only after merlin.

Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
2019-10-13 20:36:49 +09:00
..
autoload.el
config.el Fix tuareg-find-alternate-file binding 2019-10-13 20:36:49 +09:00
doctor.el
packages.el
README.org lang/ocaml: update README 2019-09-13 22:04:53 -04:00

lang/ocaml

Description

This module adds OCaml support to Doom Emacs, powered by tuareg-mode.

Module Flags

This module provides no flags.

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-mode is activated whenever a .merlin file is found (including in a parent directory) and ocamlmerlin executable is present
  • Line-based auto-indentation is provided by ocp-indent, if it is available.

Configuration

  • If :completion company is enabled then autocomplete is provided by merlin
  • When :tools flycheck is enabled then flycheck-ocaml is activated to do on-the-fly syntax/type checking via merlin, otherwise this is only done when the file is saved.
  • Spell checking is activated in comments if :tools flyspell is active
  • A REPL is provided if utop is installed and :tools eval is active
  • If :editor format is enabled, the ocamlformat executable is available and there is an .ocamlformat file present then format-all-buffer is bound to ocamlformat, otherwise to ocp-indent
  • If :editor multiple-cursors is enabled then identifiers can be refactored with v R and multiple cursors (this correctly matches identifier occurrences according to scope, it is not purely a textual match)
  • If :emacs imenu is enabled then top level symbols (modules, type, functions, etc.) can be looked up using SPC / i

Run bin/doom refresh to install all packages and make doctor to diagnose missing tools.

Appendix

Commands

Command Key Description
merlin-type-enclosing SPC m t display type under point
tuareg-find-alternate-file SPC m a switch between .ml and .mli
merlin-locate gd lookup definition
merlin-occurences SPC c D lookup references
merlin-document K lookup documentation
merlin-imenu SPC / 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-pretty-symbols! is called with the full tuareg prettify symbol list, this can cause columns to change as certain keywords are shortened (e.g. fun becomes λ.
  • tuareg-opam-update-env is called the first time tuareg is loaded