[ANN] VSCode OCaml Platform v1.7.0 - v1.8.0

On behalf of the VSCode development team, I’m happy to announce a new release of VSCode’s OCaml Platform extension.

Release 1.7.0 was broken, so we released 1.8.0 a few hours later with a fix and some additional features.

The most important change with this release is the automatic installation of Platform tools.

Previously, the extension needed Platform tools (for now, ocaml-lsp-server and ocamlformat) to be installed in the selected sandbox to work. This is not longer the case: when selecting a sandbox, the extension will setup a private Opam switch with the same version of the compiler and install the platform tools in it. If the tools are installed in the sandbox, they will be used instead of the private switch, but it is not recommended to install them manually anymore.

Of course, that means that we have to set up a new switch every time you select a sandbox with a new compiler version, and this might take a few minutes, but your patience is well rewarded:

  • The platform tools are global to all of your projects with the same compiler version: no more wasting time installing lsp and ocamlformat in every switch
  • The platform tools don’t interfere with your local dependencies.
  • Lastly, and most importantly for newcomers: if you have Opam on your system, you don’t need to do anything to have a working environment.

That’s a pretty big change to how you use the extension, so don’t hesitate if you have any questions and report any issue you’re having here.

Another addition is the integration with a REPL (Utop or OCaml toplevel). You can now select a piece of code and press Shift+Enter to run it in a REPL. Let us know what you think!

Changelog

1.8.0

  • Highlight OCaml source code inside Cinaps comments (#547)

  • Show the output of shell commands in an output channel.

    The output channel is automatically focused when running a package management command from the OCaml activity tab (#541)

  • Fix highlighting of float literals with a trailing decimal point (#548)

  • Ask for confirmation when removing opam packages or switches (#551)

1.7.0

  • Fixed an issue when uninstalled Opam packages still appear in the roots field of Opam’s switch-state file (#517)

  • Fixed detection of local Opam switch on Windows (#518)

  • vscode-ocaml-platform now depends on ocaml-lsp-server.1.3.0

  • Add a command to open a Utop REPL in the current sandbox (#504)

  • Add a code evaluation command that sends selected expressions to the REPL (#504)

  • Install OCaml Platform tools automatically (#463)

    The platform tools (a.k.a toolchain) are installed in a private opam switch that should only be used by vscode-ocaml-platform.

22 Likes

Is there a way to control the version of the tools? That’s a requirement to use older versions of ocamllsp (to continue using it on 4.06 code) and ocamlformat (until we migrate to a more recent version).

Is there a way to disable to automatic setup?

One possible unexpected behavior: I am using a custom version of ocaml (4.09 + minor patches) but the extension compiles the official 4.09.

Also so far I’ve opened only one project in which I’m using ocaml 4.09, but the extension created 2 switches in ~/.vscode-ocaml/opam

$ opam sw --root=~/.vscode-ocaml/opam
#  switch                         compiler                    description
   default                        ocaml-base-compiler.4.12.0  default
→  vscode-ocaml-toolchain.4.09.0  ocaml-base-compiler.4.09.0  vscode-ocaml-toolchain.4.09.0

Not at the moment. Once we have binaries for the Platform tools, this could be a possibility, but until then, it’s not realistic to set up a switch per tool version (even only ephemeral).

If using the latest version of the tools is not a possibility, I’d suggest staying on your current workflow (installing the version of lsp and ocamlformat you want in the sandbox). The current version of the extension does not allow you to skip the toolchain setup, but we’ll add a confirmation prompt in the next release.

Thanks for the report on the two switches, would you mind opening an issue for this?

Another suggestion I have is to add a manual mode so that this setup can be triggered and manipulated by hand but would not happen automatically in the backend otherwise. I see at least two reasons why I would want this

  1. I don’t want my editor to not work for some time because an upgrade has suddenly been launched in the background (I noticed there is an opam upgrade that is launched when the editor starts, I don’t know if it happens at other times too)
  2. When traveling I commonly use my phone as a hotspot or a wifi with limited data that I definitely don’t want to waste on opam updates/upgrades
4 Likes

Hi,

The page on the extension on the VsCode marketplace still contains the following:

Quick start

  1. Install this extension from the VSCode Marketplace (or by entering ext install ocamllabs.ocaml-platform at the command palette Ctrl+Shift+P (Cmd+Shift+P on MacOS)
  2. Open a OCaml/ReasonML project ( File > Add Folder to Workspace... )
  3. Install OCaml-LSP with opam or esy. E.g. opam install ocaml-lsp-server

IIUC this third step isn’t needed anymore, so it could be removed?

The README was changed initially. Unfortunately, we had to revert the automatic installation feature because of some usability problems:

1.8.1

  • Revert automatic installation of platform tools

    The feature is not flexible enough and caused issues with multiple users. We
    will work on making it more flexible and fit more workflows before releasing
    it.

Thanks for the answer. Too bad this was reverted because it would have really eased the installation process for OCaml beginners (who have never been taught about opam).

This feature has not been abandoned, it is just getting more polished before to be released