# Ideal OCaml setups with VIM, Emacs, IntelliJ/IDEA?

**URL:** <https://discuss.ocaml.org/t/ideal-ocaml-setups-with-vim-emacs-intellij-idea/4037>\
**Category:** Learning\
**Created:** [July 5, 2019, 8:10am UTC](https://discuss.ocaml.org/t/ideal-ocaml-setups-with-vim-emacs-intellij-idea/4037 "2019-07-05T08:10:12Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![zeroexcuses](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/zeroexcuses/32/1692_2.png) [@zeroexcuses](https://discuss.ocaml.org/u/zeroexcuses)\
**Post date:** [July 5, 2019, 8:10am UTC](https://discuss.ocaml.org/t/ideal-ocaml-setups-with-vim-emacs-intellij-idea/4037/1 "2019-07-05T08:10:12Z")

</div>

I am new to OCaml and trying to setup a productive OCaml environment.

I am familiar with VIM (first editor), Emacs (when I saw how well C-x C-e REPLs worked), IntelliJ/IDEA (when I saw Java/Kotlin auto completion “just worked”).

My current IDE of choice is IntelliJ/IDEA. I have [https://github.com/reasonml-editor/reasonml-idea-plugin](https://github.com/reasonml-editor/reasonml-idea-plugin) installed, but I don’t think I’m using it right.

Can someone provide links for:

- ideal VIM/OCaml setup
- ideal Emacs/OCaml setup
- ideal IntelliJ/OCaml setup  
? (I want to study all 3 and pick one.)

The main features that matter to me are:

- easy access to the OCaml REPL
- “it just works” reference resolution – I should be able to put cursor over a Struct / Field / Function, hit some hot key, and jump to (1) where it is defined and (2) list of where it is used
- hot key to show all Structs (which starts “narrowing” to completion candidates as I type), and jumps to Struct definition when I hit ENTER
- easy way to run unit tests
- auto jump to correct line on compile errors

---

<div class="post-metadata">

**Author:** ![dbuenzli](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/dbuenzli/32/18_2.png) [@dbuenzli](https://discuss.ocaml.org/u/dbuenzli)\
**Post date:** [July 5, 2019, 8:35am UTC](https://discuss.ocaml.org/t/ideal-ocaml-setups-with-vim-emacs-intellij-idea/4037/2 "2019-07-05T08:35:26Z")

</div>

> [@zeroexcuses](#):
>
> ideal Emacs/OCaml setup

Not sure if it’s ideal and but here are a [few steps](https://gist.github.com/dbuenzli/a797e398cb3f6503b6e0b5f34249648a) to get you started with `emacs`.

---

<div class="post-metadata">

**Author:** ![Freyr666](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/freyr666/32/591_2.png) [@Freyr666](https://discuss.ocaml.org/u/Freyr666)\
**Post date:** [July 5, 2019, 8:58am UTC](https://discuss.ocaml.org/t/ideal-ocaml-setups-with-vim-emacs-intellij-idea/4037/3 "2019-07-05T08:58:32Z")

</div>

Since [merlin](https://github.com/ocaml/merlin) supports LSP protocol, completions, jump-to-definitions and other such stuff should just work in the majority of editors. REPL integration could be a little bit trickier, tho. There should be a mode for editor supporting [utop](https://github.com/ocaml-community/utop).

There is `reasonml` plugins for both Idea and VS Code, which provide a good support out-of-the box. However, neither supports repl yet AFAIK. Emacs have a good utop and merlin integration, if you want to give it a try, both [Doom-emacs](https://github.com/hlissner/doom-emacs/tree/develop/modules/lang/ocaml) and spacemacs have a preconfigured OCaml support.

---

<div class="post-metadata">

**Author:** ![zeroexcuses](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/zeroexcuses/32/1692_2.png) [@zeroexcuses](https://discuss.ocaml.org/u/zeroexcuses)\
**Post date:** [July 5, 2019, 9:34am UTC](https://discuss.ocaml.org/t/ideal-ocaml-setups-with-vim-emacs-intellij-idea/4037/4 "2019-07-05T09:34:53Z")

</div>

Merlin / utop is breaking assumptions I made regarding how OCaml works.

A slightly different question: what are popular work flows that proficient OCaml programmers use? (Links to tutorials / setups / screencasts would be great).

---

<div class="post-metadata">

**Author:** ![XVilka](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/xvilka/32/5334_2.png) [@XVilka](https://discuss.ocaml.org/u/XVilka)\
**Post date:** [July 5, 2019, 10:12am UTC](https://discuss.ocaml.org/t/ideal-ocaml-setups-with-vim-emacs-intellij-idea/4037/5 "2019-07-05T10:12:30Z")

</div>

Here is [my Vim setup](https://gist.github.com/XVilka/2d55cfe4fd134ffd26049718dc6cdc7b). I program not only OCaml though, but some config parts can be useful. I am far from being proficient though, more like an average, closer to the beginner one.

Also note the recent [update](https://github.com/vim/vim/commit/790c18bfa5dfeca51749b752dddc41e60cb3fa54) of OCaml and Dune support in the mainline Vim. So Vim patch level above 8.1.1630 is recommended. It also should become a part of [NeoVim 0.4 release](https://github.com/neovim/neovim/milestone/21) in a month.

---

<div class="post-metadata">

**Author:** ![XVilka](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/xvilka/32/5334_2.png) [@XVilka](https://discuss.ocaml.org/u/XVilka)\
**Post date:** [August 2, 2019, 4:29am UTC](https://discuss.ocaml.org/t/ideal-ocaml-setups-with-vim-emacs-intellij-idea/4037/6 "2019-08-02T04:29:12Z")

</div>

A small update: the OCaml and Dune runtime files landed in NeoVim as well, so you can already try them if you use it from git: [https://github.com/neovim/neovim/commit/87140f234ac1f152f6f273dee5ab1e42c7b1d78b](https://github.com/neovim/neovim/commit/87140f234ac1f152f6f273dee5ab1e42c7b1d78b)

---

<div class="post-metadata">

**Author:** ![zbroyar](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/zbroyar/32/3789_2.png) [@zbroyar](https://discuss.ocaml.org/u/zbroyar)\
**Post date:** [August 2, 2019, 2:54pm UTC](https://discuss.ocaml.org/t/ideal-ocaml-setups-with-vim-emacs-intellij-idea/4037/7 "2019-08-02T14:54:48Z")

</div>

I agree with one of commenters above: as of now the most value in any editor (while working with OCaml code 🙂 ) you get from merlin.

My personal Emacs setup is pretty straightforward and simple: tuareg-mode + merlin. But now I’m moving my projects to dune with aim to integrate my workflow with its utop feature.

---

<div class="post-metadata">

**Author:** ![hgiraud](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/hgiraud/32/996_2.png) [@hgiraud](https://discuss.ocaml.org/u/hgiraud)\
**Post date:** [November 17, 2019, 11:50am UTC](https://discuss.ocaml.org/t/ideal-ocaml-setups-with-vim-emacs-intellij-idea/4037/8 "2019-11-17T11:50:20Z")

</div>

@zeroexcuses I published a video this week to explain how to import an ocaml project with latest plugin version. You can find it here: [https://www.youtube.com/watch?v=V8r5ys-6QUI](https://www.youtube.com/watch?v=V8r5ys-6QUI)  
I hope you can find it useful.  
It’ll give you completion/documentation out of the box for ocaml stdlib. And it works on any OS (hint: Windows)  
Idea plugin is more focused on ReasonML because that’s my main usage now, but I’m slowly integrating more OCaml related functionalities. But far from “ideal” 🙂
