Skip to content

Feature Proposal: Integrate ocamlformat and ocaml-lsp-server into Opam Environments #577

Description

@TheRealOwenRees

To improve the developer experience and streamline the code review process, I propose adding ocamlformat and ocaml-lsp-server to the default opam installation for both the student switch and the Exercism development switch environments.

Standardizing the toolchain at the environment level ensures that students have a modern IDE experience out of the box and reduces friction during the submission process.

Proposed Changes

1. Toolchain Expansion

Include the following packages in the environment setup scripts/documentation:

  • ocaml-lsp-server: Provides advanced IDE features like autocompletion, type-checking on hover, and real-time error highlighting. This works in conjunction with the Official OCaml VS Code Extension.
  • ocamlformat: Automates code formatting based on a defined configuration.

2. Configuration & Automation

  • .ocamlformat file: Add a default configuration file to the repository root. This allows the OCaml platform to automatically format code on save.

  • Makefile Integration: Add a convenience command to the Makefile to support CLI-based formatting for users who prefer the terminal or use different editors:

    fmt: opam exec -- dune fmt
    

3. Why?

  • Streamlined Code Reviews: Standardizing code style removes the need for mentors to comment on formatting, allowing them to focus on logic and idiomatic OCaml.

  • Reduced CI/CD Overhead: Automated formatting prevents "style-only" build failures, reducing the number of resubmissions and saving CI/CD runner resources.

  • Improved Onboarding: New students benefit immediately from functional linting and highlighting, which significantly lowers the barrier to entry for the language.

References

OCaml Documentation: Formatting Your Code
Dune Documentation: Formatting

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions