fakenickels / vscode-ocaml-platform

Visual Studio Code extension for OCaml

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

VSCode OCaml Platform

Main workflow

Visual Studio Code extension for OCaml and relevant tools.

This plugin is alpha quality. Use at your own risk and please report any bugs you encounter.

Quick start

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

BuckleScript

There is currently no way of installing OCaml-LSP natively for BuckleScript projects. As a fast workaround, you can use esy:

  1. Install esy
npm install esy --global
  1. Add esy.json to the project root with following content:
{
  "dependencies": {
    "@opam/ocaml-lsp-server": "ocaml/ocaml-lsp:ocaml-lsp-server.opam",
    "@opam/reason": "*",
    "ocaml": "4.6.x"
  }
}
  1. Install and build packages
esy

Features

  • Syntax highlighting
    • ATD
    • Cram tests
    • Dune
    • Menhir
    • Merlin
    • META
    • OASIS
    • OCaml
    • OCamlbuild
    • OCamlFormat
    • OCamllex
    • opam
    • ReasonML
  • Indentation rules
  • Snippets
    • Dune
    • OCaml
    • OCamllex
  • Task Provider
    • Dune

Configuration

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.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.

Commands

You can execute it by entering the following command at the command palette Ctrl+P.

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)

Requirements

About

Visual Studio Code extension for OCaml

License:ISC License


Languages

Language:OCaml 89.8%Language:JavaScript 9.7%Language:Makefile 0.2%Language:Standard ML 0.2%Language:Reason 0.1%