Setup via package.elĪn installable core merlin package is available via MELPA, along with further small integration packages merlin-company, merlin-iedit and merlin-ac which users can install according to their needs. (require 'merlin-ac) auto-complete.el completionĪ more comprehensive documentation can be found on the emacs-from-scratch wiki. (require 'merlin-company) company.el completion (require 'merlin-iedit) iedit.el editing of occurrences Uncomment these lines if you want to enable integration with the corresponding packages (add-hook 'tuareg-mode-hook #'merlin-mode) (autoload 'merlin-mode "merlin" "Merlin mode" t) (setq merlin-command "/ocamlmerlin") needed only if ocamlmerlin not already in your PATH emacs: (push "/emacs/site-lisp" load-path) directory containing merlin.el Merlin comes with an emacs library (file: emacs/merlin.el) that implements a minor-mode that is supposed to be used on top of tuareg-mode.Īll you need to do is add the following to your. The default configuration can be seen in: /merlin/vim/plugin/merlin.vimĪfter adding merlin to vim runtime path, you will probably want to run :helptags /merlin/vim/doc to register Merlin documentation inside vim.Ī more comprehensive documentation can be found on the vim-from-scratch wiki. The only setup needed is to have the following directory in vim runtime path (append this to your. Makes sure that ocamlmerlin binary can be found in PATH. "/share" if you explicitly specified a prefix when configuring Merlin Printed by the command opam var share, if you used opam In the rest of the document, refers to the directory where Merlin data files are installed. To set up Emacs and Vim, you need to instruct them to run the appropriate script when an OCaml file is opened. You can pass an explicit prefix to dune, using -prefix. If you haven't encountered any errors in the previous step, just run: dune install -p dot-merlin-reader,merlin In that case you'll also need an extra dependency: menhir. Note: if you want to work on merlin, you'll want to avoid the -p merlin, to build in dev mode, with some extra warnings enabled. Compilationĭependencies: ocamlfind, yojson >= 1.6.0, dune >= 2.7.
Note: if you're using an older version of OCaml (between 4.02 and 4.10) you will want to build the 3.4 branch, although it won't contain the most recent features.
The main branch is usually synchronized with the branch compatible with the latest (almost-)released version of OCaml. So, for instance, OCaml 4.11.* maps to branch 411. Since version 4.0, merlin's repository has a dedicated branch per version of OCaml, and the branch name consist of the concatenation of OCaml major version and minor version. You can also configure the editor yourself, if you prefer. Opam-user-setup takes care of configuring Emacs and Vim to make best use of your current install. If you have a working Opam installation, install Merlin running the following two commands in terminal: opam install merlin To get editor support with Merlin in other editors, see this. Merlin is an editor service that provides modern IDE features for OCaml.Įmacs and Vim support is provided out-of-the-box.