[ANN] Backstage OCaml: ocaml.nvim - A Neovim Plugin for OCaml

We’re excited to announce ocaml.nvim, a new Neovim plugin actively being developed by Tarides that brings advanced OCaml development features to Neovim users. Think of it as the Neovim sibling of ocaml-eglot, which we released earlier this year for Emacs users.

What is ocaml.nvim?

Modern code editors communicate with programming languages through the Language Server Protocol (LSP), which provides essential features like syntax checking, code navigation, and auto-completion. However, OCaml’s language server exposes powerful custom commands beyond what generic LSP clients can access.

ocaml.nvim works alongside generic Neovim LSP plugins like nvim-lspconfig, providing direct access to advanced ocamllsp features without requiring complex editor-side logic. The plugin gives you access to all the advanced Merlin commands not supported by generic LSP clients.

Key Features

Typed Holes Navigation - Navigate between typed holes (_) and interactively substitute them with the Construct command.

Semantic Navigation - Move through your code semantically: jump between expressions, parent let bindings, modules, functions, and match expressions.

Phrase Navigation - Move between OCaml phrases (top-level definitions) in your buffer.

Many more features are in development, including alternating between .ml and .mli files, type enclosing, and pattern matching generation.

Getting Started

Installation is straightforward with lazy.nvim:

require("lazy").setup({
  { "tarides/ocaml.nvim",
    config = function()
      require("ocaml").setup()
    end
  }
})

The plugin complements your existing LSP setup—you’ll continue to use Neovim’s built-in LSP for standard features while ocaml.nvim adds OCaml-specific capabilities.

Project Status

The ocaml.nvim repository is now public on GitHub, with comprehensive documentation, a feature table, and screencast demonstrations. We’re working towards a stable 1.0 release and welcome feedback from the community.

Try out ocaml.nvim and let us know what you think! For questions or feedback, you can post an issue on the ocaml.nvim GitHub repository.

27 Likes

This looks cool!

So far I have remained on (archeo-)vim and still use the non-lsp merlin version. I understand that the trend has been towards LSP for a while now, and the new plugin enhances functionality by complementing LSP’s limitations.

What would I gain by switching to it?

Could I also use it with the original vim and corresponding LSP client?

Looking at the plugin, it’s using neovim APIs, so I’d say unlikely.

From what I understand, at least for now, the added functionality are already in Merlin, so I don’t think there is much for you to gain. (I’d argue there is much to gain to switching to neovim+lsp, but that another discussion :slightly_smiling_face: )

I recently tried nvim + ocaml but can’t find solid lsp/syntax support, so I already move on helix/zed - both support Ocaml out of box with LSP + syntax.

neovim indeed need to have much simpler installation process for plugins else it will lose the ground to more modern editors..

It’s coming:

This plugin is designed to provide Neovim users with the full power of Merlin, combining Neovim’s native LSP features with this plugin, which provides Merlin’s core features.
If you are using the legacy Merlin for Vim, switching to ocaml.nvim ensures you keep all of Merlin’s core features while moving to an LSP-based solution, the new standard for editor tooling, and a neovim-native way to integrate these features..
While the legacy plugin still works, adopting an LSP-based configuration is a forward-looking move.
To be honest, one of the major reasons why we want people to use LSP and the new plugin is that it makes the maintenance easier.
In fact, instead of maintaining all the features for every editor, it relies on LSP to provide the standard features across editors.
We just need to design a dedicated plugin for the extra features of Merlin encoded by custom requests.
The maintenance is easier because a fix on LSP is a fix on all the editors that use it, and we just need to maintain the extra features plugin by plugin.

4 Likes