Skip to content

Latest commit

 

History

History
102 lines (68 loc) · 3.46 KB

File metadata and controls

102 lines (68 loc) · 3.46 KB

VS Code Setup

Native VS Code integration with the Dev Containers extension.

Note: This guide targets VS Code. It has not been tested with Cursor or Google Antigravity.

Prerequisites

Podman alternative: On macOS, Podman works as a drop-in replacement for Docker Desktop. Install it via brew install podman, then create a docker alias so the DevContainer CLI finds it:

sudo ln -s $(which podman) /usr/local/bin/docker

See From Docker to Podman: VS Code DevContainers for details.

Quick start

  1. Clone the repository:

    git clone https://github.com/tarides/ocaml-devcontainer.git
  2. Open in VS Code:

    code ocaml-devcontainer
  3. When prompted, click "Reopen in Container"

    • Or: Press Ctrl+Shift+P → "Dev Containers: Reopen in Container"
  4. Wait for the container to start (~2-3 minutes first time)

OCaml Platform extension

The OCaml Platform extension is automatically installed and provides:

  • Syntax highlighting
  • Code completion
  • Type information on hover
  • Go to definition
  • Find references
  • Error diagnostics

Using the TSan variant

For ThreadSanitizer support, open the .devcontainer-tsan/ configuration:

  1. Press Ctrl+Shift+P → "Dev Containers: Reopen in Container"
  2. Select the "OCaml Development (TSan)" configuration

Then switch to the TSan compiler:

opam switch ocaml+tsan
eval $(opam env)

Reload the window (Ctrl+Shift+P → "Developer: Reload Window") so the extension picks up the new switch.

See the README for details.

Debugging

GDB and LLDB are available for native debugging. VS Code's debugger can be configured to use them.

Data persistence

The workspace folder is mounted from your host, so your files are always safe on disk. State inside the container (installed packages, shell history) persists as long as you stop and restart the container. Rebuilding the container (Ctrl+Shift+P → "Dev Containers: Rebuild Container") resets that state.

Troubleshooting

Extension not working

  1. Check that the container started successfully
  2. Reload the window
  3. Check the OCaml extension output panel

Slow IntelliSense

This can happen with large projects. Try:

dune build  # Build first to generate .merlin files

Container won't start

  1. Check Docker is running
  2. Try rebuilding: Ctrl+Shift+P → "Dev Containers: Rebuild Container"
  3. Check Docker logs for errors

Tips

  • Use Ctrl+Shift+P → "OCaml: Restart Language Server" if LSP gets confused
  • Use the "Problems" panel to see all errors and warnings

See the README for installed tools, common commands, and switch details.