Visual Studio Code extension for OCaml
Visual Studio Code extension for OCaml and relevant tools.
Please report any bugs you encounter.
ext install ocamllabs.ocaml-platformat the command palette Ctrl+Shift+P (Cmd+Shift+P on MacOS)
File > Add Folder to Workspace...)
opam install ocaml-lsp-server
Install OCaml for Windows and make sure the
ocaml-envprogram is accessible on the PATH (
ocaml-envis in the
usr/local/binfolder relative to the installation directory).
The new ReScript syntax (
resand
resifiles) is not supported, you should use rescript-vscode instead.
ReasonML, as an alternative syntax for OCaml, is supported out-of-the-box, as long as
reasonis installed in your environment.
If you're looking for a way to use OCaml or ReasonML syntax in a ReScript project, you'll need to install
ocaml-lspin your environment. We recommend using Esy for this:
npm install esy --global
esy.jsonto the project root with following content:
{ "dependencies": { "@opam/ocaml-lsp-server": "*", "@opam/ocamlfind-secondary": "*", "@opam/reason": "*", "ocaml": "4.6.x" } }
esy
This extension provides options in VSCode's configuration settings. You can find the settings under
File > Preferences > Settings.
| Name | Description | Default | | ---------------------------------- | ------------------------------------------------------------------------------------------------------- | ------- | |
ocaml.sandbox| Determines where to find the sandbox for a given project |
null| |
ocaml.dune.autoDetect| Controls whether dune tasks should be automatically detected. |
true| |
ocaml.trace.server| Controls the logging output of the language server. Valid settings are
off,
messages, or
verbose. |
off| |
ocaml.useOcamlEnv| Controls whether to use ocaml-env for opam commands from OCaml for Windows. |
true| |
ocaml.terminal.shell.linux| The path of the shell that the sandbox terminal uses on Linux |
null| |
ocaml.terminal.shell.osx| The path of the shell that the sandbox terminal uses on macOS |
null| |
ocaml.terminal.shell.windows| The path of the shell that the sandbox terminal uses on Windows |
null| |
ocaml.terminal.shellArgs.linux| The command line arguments that the sandbox terminal uses on Linux |
null| |
ocaml.terminal.shellArgs.osx| The command line arguments that the sandbox terminal uses on macOS |
null| |
ocaml.terminal.shellArgs.windows| The command line arguments that the sandbox terminal uses on Window |
null|
If
ocaml.terminal.shell.*or
ocaml.terminal.shellArgs.*is
null, the configured VSCode shell and shell arguments will be used instead.
You can execute it by entering the following command at the command palette Ctrl+P (Cmd+Shift+P on MacOS).
| Name | Description | Keyboard Shortcuts | Menu Contents | | ---------------------------- | ------------------------------------------- | ------------------ | ------------- | |
ocaml.select-sandbox| Select sandbox for this workspace | | | |
ocaml.server.restart| Restart language server | | | |
ocaml.open-terminal| Open a terminal (current sandbox) | | | |
ocaml.open-terminal-select| Open a terminal (select a sandbox) | | | |
ocaml.current-dune-file| Open Dune File (located in the same folder) | | |