Ocaml-lsp proper nvim setup

I am using

per the instructions:
install the server

opam install ocaml-lsp-server

then in the lua config


but type checking doesn’t work unless I first run dune build and re-open the file

Is there anything I’m missing for things to auto-compile when necessary and have type checking without file reloads?


I followed https://www.rockyourcode.com/setup-ocaml-with-neovim/ but set up merlin only, no lsp. The instruction uses some more plugins for lsp.

In my NVim setup, I don’t get the issue you mention apart from seeing something like "No config found for file "main.ml" in "bin". Try calling 'dune build' before first ‘dune build’. My lsp setup is here neovim-ocaml/lspconfig.lua at main · nyinyithann/neovim-ocaml · GitHub.

1 Like

You can run dune build --watch @check somewhere, and then saving the file will trigger a build and make that warning go away.