Ocaml-lsp-server dune editor setup/workflow

I’m using

  • nvim
  • ocaml-lsp-server
  • dune
  • coc

the setup works generally well, but I find myself constantly needing to:

  • manually rebuild the project for new types to appear, for type checking to work for newly added files and etc.
  • manually reload the opened file after the build, so that type checking works

is my setup ‘wrong’?

is this how the lsp is expected to work?

and what is your workflow to automate that?

If you run dune build in a watching mode, ie dune build --watch, the experience gets pretty smooth.

6 Likes

Apart from using dune in watch mode, there’s another caveat to keep in mind: lsp only type checks your source after you edit it. So if your source becomes invalid because you’ve edited the interface of some other module that’s a dependency, you will not see the error the reflected in your editor until you save an edit.

In dune 3.0, we’re going to have deeper integration with watch mode. It shouldn’t be too hard to think of a workaround for this issue.

5 Likes