What's your setup for OCaml development?


#1

What I want from IDE is just auto-formatting and code completion. Embedded console w/ compilation/run by hotkey also would be nice to have.
What are you guys are using?


#2

Have you tried Visual Studio Code with the vscode-reasonml extension? It supports OCaml with completion and tasks to build the project. Also has an embedded console. The only thing you might need to fiddle with is auto-formatting–the options are ocp-indent and ocamlformat.


#3

I think both Vscode and neovim can meet your requirements.

https://github.com/reasonml-editor/vscode-reasonml provides excellant ocaml support on vscode (formatting + code completion and more)

On neovim the plugins I use are following:


#4

Emacs with Tuareg — formatting, syntax highlighting, launching compilation and click to go to the error location, REPL — and Merlin — code completion, type queries, documentation queries.


#5

Is there a way to get instant automatic indentation with vscode by hitting tab, like in emacs? If so, what did you do to set it up?

(I’m currently using vscode+reasonml+merlin for reading other people’s code and emacs+tuareg+merlin+ocp-indent for writing new code. I’d like to switch completely to vscode if possible)


#6

I’m using spacemacs. With tuareg, merlin etc. for OCaml stuff and magit to interact with git repositories.


#7

vim (lots of remote editing makes it easier to stick to one environment locally as well):


#8

NeoVim with the following set of plugins:

  • ALE — shows lines with errors/warnings from Merlin
  • mucomplete — simple autocomplete engine, tries to query merlin, then buffer keywords, paths
  • gd — go to definition

NeoVim is running inside tmux inside Kitty terminal emulator — I found this combination is the fastest one on macOS (tried Alacritty, iTerm2, Terminal.app before). Usually a single full screen window with two panes split horizontally.


#9

I have a similar setup: ALE and merlin on vim 8. Unfortunately, ALE errors take over the statusline whenever I am on a line with an error, which prevents me from displaying e.g. a type or anything else with merlin on that line. I would much prefer if a newer message would overwrite ALE messages. Does anyone have a solution for that other than completely switching off ALE messages in the status line? (sorry for hijacking)


#10

Emacs, with Tuareg, Merlin, etc. are my IDE. I’m very happy with the setup.


#11

You might be able to rebind the Tab key in VSCode to run ocp-indent, e.g. I haven’t tried :slight_smile:


#12

Vim 8 + Merlin. It’s perfect.


#13

It’s curious not one person mentioned Atom. It’s great if you are a terminal person. We’re at it all the time and all. But I think I’ll never think of vim-like editors as an IDE. I simply don’t believe the vibe “you are only truly good if you live in a terminal”.

Atom is one of the most intuitive, configurable, and productive tools to work with OCaml you can find today. Compared to VSCode, I miss the mouse-hover tooltips showing type signatures, but not much else. And it is certainly great for automation. I’m crazy fast with it. Three are a few packages and tweaks needed to make OCaml like workflow smooth, but usually exploring the choices pays off.


#14

It’s curious not one person mentioned Atom.

Atom was a really interesting idea, and I wanted it to be good, but it’s just too memory intensive and bloated. I have had trouble using it for anything other than tests. It’s bad enough having to run electron apps like Slack in my environment — if you try using Atom on a machine without insane amounts of memory you start paging, and the amount of CPU needed to do anything beyond the simplest tasks is crazy. JavaScript simply isn’t a reasonably performing implementation language for large programs, and that’s ignoring its flaws as a language.

Emacs is not a “terminal” editor, and vim isn’t these days either. Both have quite reasonable GUI modes. Both are fully programable environments, and both are clearly IDEs if they’re set to behave that way.

If you have Tuareg and Merlin loaded, Emacs does pretty much anything that any other OCaml environment can, and of course it’s also still Emacs so it does all the things Emacs can do. (I’m not a vim user but I fully respect people who are, there’s nothing wrong with vim.)


#15

@perry, I understand your opinion, and I’m well aware of Atom’s performance problems. And still think it’s worthy. For my needs working with OCaml, Atom is not only a viable solution, it’s pretty much unmatched. I like the idea that we can have this conversation. We have options.

I disagree with the idea that’s something really bad about building an IDE with JS. The problem is not the evolution of web-apps, but the lack of interest in building native applications as good as the web-based. I would rather keep and tweak the intuitive interfaces, and focus on coding than having to figure out how to do multi-line editing or working with multiple projects on the terminal.


#16

The problem is not the evolution of web-apps, but the lack of interest in building native applications as good as the web-based.

That’s not true. I’d love to build native applications but these days the GUI bindings for everything but web apps seem to be rotting away. If there was a set of OCaml bindings for the native GUI widgets on macOS for example I wouldn’t even think about web apps on the desktop. I think the biggest problem is that everyone is being pushed in that direction, and not that people are all choosing it of their own free will. But that’s another story and has little to do with development environments I’m afraid.

I would rather keep and tweak the intuitive interfaces, and focus on coding than having to figure out how to do multi-line editing or working with multiple projects on the terminal.

Emacs and Vim aren’t terminal based. If you want to open things in the terminal you can, but they’re GUI editors just like Atom is. Emacs has an extension language (elisp, not javascript) and huge suites of applications written for it. Vim has its own extension language (which I have no experience with.)


#17

I’ve found Visual Studio Code (which is essentially unrelated to Visual Studio; more like Microsoft’s Atom, open-source and cross platform) to be quite excellent, especially for beginners. Easy to set up for OCaml, and works very smoothly. I also hear it performs better than Atom, but I haven’t done enough to know myself.

That said, I still use Emacs, Tuareg and Merlin for real work.


#18

Same problem, didn’t solve it yet.


#19

I’m also seconding VSCode with vscode-reasonml extension (search “OCaml and Reason IDE” on the extensions tab). It’s nice. I’m also using Spacemacs with its OCaml layer interchangeably with VSCode. Setting up either VSCode or Spacemacs are very low friction to get a decent dev environment easily.


#20

Any chance to see your Emacs setup (the only OCaml part eventually) somewhere?

Thank you.