Page
Library
Module
Module type
Parameter
Class
Class type
Source
Merlin is an editor service that provides modern IDE features for OCaml.
Emacs and Vim support is provided out-of-the-box. External contributors added support for Visual Studio Code, Sublime Text and Atom.
If you have a working Opam installation, Merlin is only two commands away:
opam install merlin
opam user-setup install
opam-user-setup takes care of configuring Emacs and Vim to make best use of your current install.
You can also configure the editor yourself, if you prefer.
Dependencies: ocaml >= 4.02.3, ocamlfind, yojson >= 2.0.0, dune >= 1.8.
dune build -p merlin
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. In that case you'll also need an extra dependency: menhir.
The LSP server has moved to its own project.
If you haven't encountered any errors in the previous step, just run:
$ dune install -p merlin
You can pass an explicit prefix to dune, using --prefix
. It defaults to your current opam switch.
To setup Emacs and Vim, you need to instruct them to run the appropriate script when an OCaml file is opened.
In the rest of the document, <SHARE_DIR> refers to the directory where Merlin data files are installed.
It will usually be:
opam var share
, if you used opamMakes sure that ocamlmerlin binary can be found in PATH.
The only setup needed is to have the following directory in vim runtime path (append this to your .vimrc):
:set rtp+=<SHARE_DIR>/merlin/vim
The default configuration can be seen in:
<SHARE_DIR>/merlin/vim/plugin/merlin.vim
After adding merlin to vim runtime path, you will probably want to run :helptags <SHARE_DIR>/merlin/vim/doc
to register Merlin documentation inside vim.
A more comprehensive documentation can be found on the vim-from-scratch wiki.
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.
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)
;; Uncomment these lines if you want to enable integration with the corresponding packages
;; (require 'merlin-iedit) ; iedit.el editing of occurrences
;; (require 'merlin-company) ; company.el completion
;; (require 'merlin-ac) ; auto-complete.el completion
A more comprehensive documentation can be found on the emacs-from-scratch wiki.
An 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.
Having installed the required packages, the following code in your emacs startup file is sufficient:
(setq merlin-command "<BIN_DIR>/ocamlmerlin") ; needed only if ocamlmerlin not already in your PATH
(add-hook 'tuareg-mode-hook #'merlin-mode)
(add-hook 'caml-mode-hook #'merlin-mode)
;; Uncomment these lines if you want to enable integration with the corresponding packages
;; (require 'merlin-iedit) ; iedit.el editing of occurrences
;; (require 'merlin-company) ; company.el completion
;; (require 'merlin-ac) ; auto-complete.el completion
The wiki also contains pages for:
External contributors have implemented modes for more editors:
To use Merlin with a multi-file project, it is necessary to have a .merlin file.
Read more in the wiki to learn how to make full use of Merlin in your projects.
Most of the development happens through the github page.
The mailing list welcomes general questions and discussions.
Area/Emacs: Related to Emacs
Area/Vim: Related to Vim
Kind/Bug: This issue describes a problem
Kind/Docs: This issue describes a documentation change
Kind/Feature-Request: Solving this issue requires implementing a new feature
Kind/To-discuss: Discussion needed to converge on a solution; often aesthetic. See mailing list for discussion
Status/0-More-info-needed: More information is needed before this issue can be triaged
Status/0-Triage: This issue needs triaging
Status/1-Acknowledged: This issue has been triaged and is being investigated
Status/2-Regression: Known workaround to be applied and tested
Status/3-Fixed-need-test: This issue has been fixed and needs checking
Status/4-Fixed: This issue has been fixed!
Status/5-Awaiting-feedback: This issue requires feedback on a previous fix
You can see current areas of development in our Merlin Project Roadmaps that we keep up to date.
Merlin needs your help and contributions!
When you encounter an issue, please report it with as much detail as possible. A thorough bug report is always appreciated :)
Check that our issue database doesn't already include that problem/suggestion. You can click "subscribe" on issues to follow their progress and updates.
When reporting issues, please include:
Try to be as specific as possible:
If it seems relevant, also include information about your development environment:
Found a bug and know how to fix it? Or have a feature you can implement directly? We appreciate pull requests to improve Merlin, and any significant fix should start life as an issue first.
Help is greatly appreciated, the wiki needs love.
If the wiki didn't cover a topic and you found out the answer, updating the page or pointing out the issue will be very useful for future users.
Together with commenting on issues with direct feedback and relevant information, we use the mailing list to discuss ideas and current designs/implementations. User input helps us to converge on solutions, especially those for aesthetic and user-oriented topics.
We would like to thank all people who contributed to Merlin.
Main collaborators:
Contributors:
We would like to thank Jane Street for sponsoring and OCaml Labs for providing support and management.
And many thanks to our Bountysource backers.
Distribution and configuration:
Support for other editors: