This is an VS Code extension that provides OCaml language support.
Contributions are welcome. github repo
- Basic syntax highlighting for
*.ml
,*.mli
,*.mly
and*.mll
. ported from textmate - Auto-completion (aka. IntelliSense). powered by ocamlmerlin
- Error check on the fly (aka. Lint). powered by ocamlmerlin
- Show type information on hover. powered by ocamlmerlin
- Peek and goto definition (also provide a symbol list). powered by ocamlmerlin
- Auto indent on your type. powered by ocp-indent
- Debugger integrated. powered by ocamldebug
opam install merlin
opam install ocp-indent
This extension contributes the following settings:
ocaml.ocpIndentPath
: path to ocp-indent.ocaml.merlinPath
: path to ocamlmerlin.ocaml.lintDelay
: time to delay lint when make changes.
1). In VS Code, *.ml
is associated to F# by default, You need manually config this in settings.json
to make OCaml mode work with *.ml
file.
"files.associations": {
"*.ml": "ocaml",
"*.mli": "ocaml"
}
2). You need build with -bin-annot
flag and set build folder in .merlin
to get goto definitions works cross files.
3). Did you know vscode-ocaml works perfect with .vscode/tasks.json
. Here is an example:
# Makefile
build:
ocamlbuild -use-ocamlfind main.d.byte
clean:
ocamlbuild -clean
.PHONY: build clean
// .vscode/tasks.json
{
"version": "0.1.0",
"command": "make",
"showOutput": "always",
"tasks": [
{
"taskName": "clean"
},
{
"taskName": "build",
"problemMatcher": {
"fileLocation": "relative",
"owner": "ocaml",
"pattern": [
{
"regexp": "^File \"(.*)\", line (\\d+), characters (\\d+)-(\\d+):$",
"file": 1,
"line": 2,
"column": 3,
"endColumn": 4
},
{
"regexp": "^(?:(?:Parse\\s+)?(Warning|[Ee]rror)(?:\\s+\\d+)?:)?\\s+(.*)$",
"severity": 1,
"message": 2,
"loop": true
}
]
}
}
]
}
// .vscode/launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "OCaml",
"type": "ocamldebug",
"request": "launch",
"program": "${workspaceRoot}/main.d.byte",
"stopOnEntry": false,
"preLaunchTask": "build" // Build before launch
}
]
}
See https://github.com/hackwaly/vscode-ocaml/issues?q=is%3Aopen+is%3Aissue+label%3Abug
Support launch debug target in Integrated Terminal. Add a command to switch between module implementation/signature. Support Find references in file. More Info
Support debug variable paging. Support highlight occurrences and refactor in file. More Info
Add Windows debug support. Add remote debug support.
Add keywords completion. Add Menhir syntax over OCamlyacc syntax.
Add debugger (ocamldebug) support.
First published version.