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
TL;DR
Install the VSCode extension
ocamllabs.ocaml-platform
and the packagesocaml-lsp-server ocamlformat
in 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:
For Windows
- If you used the Diskuv OCaml (DKML) installer you will need to:
- Go to
File
>Preferences
>Settings
view (or pressCtrl ,
) - Select
User
>Extensions
>OCaml Platform
- Uncheck
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
Help Improve Our Documentation
All OCaml docs are open source. See something that's wrong or unclear? Submit a pull request.
Contribute