For development, you'll need Bun. Install it by following the instructions at bun.sh.
You need Opam, you can install it by following Opam's documentation.
With Opam installed, you can install the dependencies in a new local switch with:
make switchOr globally, with:
make depsThen, build the project with:
make buildAfter running
make installyou can run the extension from VSCode by going in the "Run and Debug" tab
(Shift + Cmd + D) and running the Extension task. This will open a new
VSCode window with only the vscode-ocaml extension activated.
You can run the test compiled with:
make testThis will run both the OCaml tests and the JavaScript ones.
To format the code, you can run:
make fmtThis will format the OCaml source code with ocamlformat, then lint-fix and
format the JavaScript source code with oxlint and oxfmt.
To submit a PR make sure you create a new branch, add the code and commit it.
git checkout -b my-bug-fix
git add fixed-file.ml
git commit -m "fix a bug"
git push -u origin my-bug-fixFrom here you can then open a PR from GitHub. Before committing your code it is very useful to:
- Format the code: this should be as simple as
make fmt - Make sure it builds: running
make build, this is also very important if you add data to the repository as it will "crunch" the data into the static OCaml modules (more information below) - Run the tests: this will check that all the data is correctly formatted and
can be invoked with
make test
User-visible changes should come with an entry in the changelog under the appropriate part of the unreleased section. PR that doesn't provide an entry will fail CI check. This behavior can be overridden by using the "no changelog" label, which is used for changes that are not user-visible.
The following snippet describes VSCode OCaml's repository structure.
.
│
├── assets/
| Static assets included in the packaged extension.
│
├── astexplorer/
| Vendored version of `astexplorer` used to provide the AST explorer for OCaml source code.
│
├── doc/
| Assets and files used for documentation.
│
├── languages/
| Definitions of the languages supported in the extension.
│
├── src/
| Source for VSCode OCaml extension.
│
├── src-bindings/
| Source for VSCode OCaml's bindings to JavaScript libraries.
│
├── syntaxes/
| Definitions of the syntaxes supported in the extension.
│
├── test/
| Unit tests and integration tests for VSCode OCaml.
|
├── dune
├── dune-project
| Dune file used to mark the root of the project and define project-wide parameters.
| For the documentation of the syntax, see https://dune.readthedocs.io/en/stable/dune-files.html#dune-project
|
├── Makefile
| Make file containing common development command.
│
├── bun.lock
├── package.json
| Package file for NPM packages. This is used to defined the JavaScript dependencies of the project.
│
├── README.md
| The documentation included in the extension's overview on the VSCode Marketplace.
│
├── vscode-ocaml.opam
└── vscode.opam
Opam package definitions.
To know more about creating and publishing opam packages, see https://opam.ocaml.org/doc/Packaging.html.