This README gives only indications on how to install merlin from source. If you want know how to install it from opam, and how to setup your environment to use merlin, have a look at the wiki.
Dependencies: ocaml >= 4.00.1, ocamlfind, ocamlbuild, yojson, menhir
$ ./configure
$ make
The configure script will check that all the dependencies are met, and will allow you to choose where to install merlin.
If you haven't encountered any error in the previous step, just run:
$ make install
In the rest of the document, <SHARE_DIR> refers to the directory where merlin data files are installed.
It will usually be:
- "/usr/local/share" if you used manual configuration merlin
- "<prefix>/share" if you explicitly specified a prefix when configuring merlin
- printed by the command
opam config var share
, if you used opam
Makes sure that ocamlmerlin binary can be found in PATH.
The only setup needed is to have the following directories in vim runtime path (append this to your .vimrc):
:set rtp+=<SHARE_DIR>/ocamlmerlin/vim
:set rtp+=<SHARE_DIR>/ocamlmerlin/vimbufsync
The default configuration can be seen in:
<SHARE_DIR>/ocamlmerlin/vim/plugin/merlin.vim
After adding merlin to vim runtime path, you will probably want to run
:helptags <SHARE_DIR>/ocamlmerlin/vim/doc
to register merlin documentation
inside vim.
-
<SHARE_DIR>/ocamlmerlin/vim -- main vim plugin directory
- plugin/merlin.vim -- sample configuration
- autoload/
- merlin.vim -- main vim script
- merlin.py -- helper script needed by merlin.vim (has to be in the same directory)
- syntax_checkers/
-- integration with syntastic (ocaml or omlet)
-- set g:syntastic_ocaml_checkers = ['merlin']
-- or g:syntastic_omlet_checkers = ['merlin']
-
<SHARE_DIR>/ocamlmerlin/vimbufsync
-- library needed by merlin vim mode to keep buffer synchronized
merlin comes with an emacs interface (file: emacs/merlin.el) that implements a minor-mode that is supposed to be used on top of tuareg-mode.
All you need to do is add the following to your .emacs:
(push "<SHARE_DIR>/emacs/site-lisp" load-path) ; directory containing merlin.el
(setq merlin-command "<BIN_DIR>/ocamlmerlin") ; needed only if ocamlmerlin not already in your PATH
(autoload 'merlin-mode "merlin" "Merlin mode" t)
(add-hook 'tuareg-mode-hook 'merlin-mode)
(add-hook 'caml-mode-hook 'merlin-mode)
merlin-mode
will make use of auto-complete-mode
(available by package.el and the MELPA repository) if is is installed.
When loading a ml file in your editor, merlin will search for a file named .merlin in the same directory as the file or in parent directories.
The ".merlin" allows you to integrate merlin with your project. Each line of this file begin with a directive name followed by zero, one or more arguments:
- S <src-dir>: add a source directory, used to find *.ml / *.mli files
- B <build-dir>: add a build directory, used to find *.cmi files
- PKG <findlib-pkg>: load a findlib package and its dependencies in merlin
- FLG <flag-list>: activates the given flags, the same effect can be achieved
by lauching ocamlmerlin with those flags.
For a full list of flags run
ocamlmerlin -help
. - REC : inform merlin that it should look for .merlin files in parent directories, and execute the directives it find in those files as well as the ones in the current file.
- EXT <extension-list>: (undocumented)
Directory are either absolute or relative to the directory containing ".merlin" file.
Merlin doesn't support (nor plan to support) Camlp4. However, a few common extensions are hardcoded:
Support for lwt, match_lwt, try_lwt / finally, for_lwt, while_lwt,
if_lwt and raise_lwt.
You need to add lwt package (with ":Use lwt" or "PKG lwt" in .merlin) for
this to work, and it may be necessary to reload buffer for this change to
take effect.
A few syntax extensions based on type-conv are supported as well. Namely :
- sexplib.syntax
- binprot.syntax
- fieldslib.syntax
- comparelib.syntax
Other common extensions which are supported :
- pa_ounit.syntax
- pa_js.syntax