Configuring Your Editor
OCaml has plugins for many editors, but the most actively maintained are for Visual Studio Code, Emacs, and Vim.
Visual Studio Code
Install the VSCode extension
ocamllabs.ocaml-platformand the packages
ocaml-lsp-server ocamlformatin your opam switch.
Install the OCaml Platform Visual Studio Code extension from the Visual Studio Marketplace.
The extension depends on OCaml LSP and ocamlformat. To install them in your switch, you can run:
$ opam install ocaml-lsp-server ocamlformat
Upon first loading an OCaml source file, you may be prompted to select the toolchain in use. Pick the version of OCaml you are using, e.g., 4.14.0 from the list. Additional information is available by hovering over symbols in your program:
- If you used the Diskuv OCaml (DKML) installer you will need to:
- Go to
Settingsview (or press
OCaml: Use OCaml Env. That's it!
- Go to
Vim or Emacs
Instead of using the LSP server, we can use Merlin directly.
$ opam install merlin
When we installed Merlin above, instructions were printed on how to link Merlin with your editor. If you do not have them visible, just run this command:
$ opam user-setup install