30 days of Emacs – Day 2
Today was all about setting up Emacs for OCaml development.
Tuareg seem to be the goto package for OCaml development. Installing it was easy enough.
;; Enable Tuareg (Emacs OCaml mode). ;; See https://github.com/ocaml/tuareg (use-package tuareg :defer t)
Unfortunately, I ran into some issues that needed fixing. The
$PATH I had configured in my shell didn't match the environment the Emacs knew about. Emacs couldn't locate asdf binaries, nor my opam binaries.
Thankfully, I found the excellent exec-path-from-shell package that sorted this out.
;; Enable exec-path-from-shell (Make Emacs use the $PATH set up by the user's shell) ;; See https://github.com/purcell/exec-path-from-shell (use-package exec-path-from-shell :if (memq window-system '(mac ns)) :config (exec-path-from-shell-initialize))
Merlin is an editor service that provides modern IDE features for OCaml. It was super easy to setup.
(use-package merlin :hook (tuareg-mode . merlin-mode))
This will enable
merlin-mode whenever the
tuareg-mode-hook was called.
ocp-indent is an indentation tool for OCaml. It comes with support for Emacs out of the box. Setting it up was as easy as setting up Merlin.
(use-package ocp-indent :hook (tuareg-mode . ocp-setup-indent)))