I’m finalizing the installation instructions for Real World OCaml and finally got around to configuring the awesome Merlin editor tool. I pretty much never configure my editor, so here are my notes on getting Merlin working with Vim completely from scratch on MacOS X (I’m on 10.9DP7, but this should work with earlier versions of MacOS X too).
First, install some basic plugin tools by following the Synastic installation instructions.
Install vim-sensible for useful defaults:
Follow the Merlin/vim from scratch directions:
Finally, add this this in your
~/.vimrc to turn everything on.
Trying it out
Read the excellent instructions at the Merlin for Vim from scratch wiki page. A few immediately useful things I did are below.
Displaying types: You can get the local type of something by typing in
\t anywhere. This is the
<LocalLeader> for anyone who has customized their setup (it is mapped to backslash by default).
Tab completing functions: You can tab-complete module signatures by pressing
Ctrl-X-O (make sure you keep Ctrl pressed the whole time). This activates vim’s OmniComplete mode. To get this to work with your external projects, create a
.merlin file. I use this for ocaml-dns for example.
Also, don’t forget to pass the
-bin-annot function to the compiler to
generate the typed-AST
cmt files. You can add
true: bin_annot to your
_tags file if you’re using OCamlbuild (in OCaml 4.01.0 or higher, and
it’ll be silently ignored on previous versions so you don’t need to worry
about breaking older OCaml compilers).