Autocompletion is only partially working (in VS Code and utop)

I’m new to both OCaml and Visual Studio Code so this is probably some kind of newbie question, however…

I have opened a hello.ml file in Visual Studio Code and when I type “String.” I get a nice window of autocompletion possibilities. However, if I type “Base.”, “Core.” or “Async.”, nothing pops up. I have just installed these packages with opam (and tried to restart Visual Studio Code).

I just tried utop, same behaviour there.

I’m running macos and have installed things through brew.

How do I fix this?

In short, you should setup your project using dune build system. After that VsCode will find out by itself what libraries you are using and how to autocomplete them

1 Like

I think OP has identified a potential improvement. Maybe ocaml-vscode-platform and/or vscode-reasonml should be configurable, to always append the default opam switch’s path (or any user-specified path) if available, as a fallback to merlin’s paths, eliminating the need for a dune-based repo for simple experiments and/or learning - utop has completion too, but some people just prefer editors.

Thanks, this helped me out with getting it to work in Visual Studio Code. Apparently, I had some other problems too, which was why it didn’t work out in utop either. So same behaviour but different reasons. Anyway, now it works on both places. Thanks.