package ocamlformat

All checked builds pass
  1. Overview
  2. Docs

Description

ocamlformat is a code formatter for OCaml. It comes with opinionated default settings but is also fully customizable to suit your coding style.

  • Profiles: ocamlformat offers profiles we predefined formatting configurations. Profiles include default, ocamlformat, janestreet.
  • Configurable: Users can change the formatting profile and configure every option in their .ocamlformat configuration file.
  • Format Comments: ocamlformat can format comments, docstrings, and even code blocks in your comments.
  • RPC: ocamlformat provides an RPC server that can be used by other tools to easily format OCaml Code.

Added to opam-repository:

README

ocamlformat

OCaml Code Formatter.

OCaml-CI Build Status

ocamlformat is a code formatter for OCaml. It comes with opinionated default settings but is also fully customizable to suit your coding style.

  • Profiles: ocamlformat offers profiles we predefined formatting configurations. Profiles include default, ocamlformat, janestreet.
  • Configurable: Users can change the formatting profile and configure every option in their .ocamlformat configuration file.
  • Format Comments: ocamlformat can format comments, docstrings, and even code blocks in your comments.
  • RPC: ocamlformat provides an RPC server that can bed used by other tools to easily format OCaml Code.

ocamlformat is part of the OCaml Platform, the recommended set of tools for OCaml.

Getting Started

Installation

To use ocamlformat, you will need OCaml and opam (the OCaml package manager) installed on your system. Visit the OCaml.org installation page for instructions.

With OCaml and opam installed, you can install ocamlformat with:

opam install ocamlformat

Usage

Formatting your code is as easy as running:

ocamlformat file.ml

To configure ocamlformat to your liking, create an .ocamlformat configuration file in your project with settings like:

profile = default
version = 0.29.0

Refer to our documentation or use ocamlformat --help for a full list of configuration options.

To make formatting your code even easier, use the dune build system:

dune fmt

Documentation

The full documentation for ocamlformat, including comprehensive user and API guides, can be found on OCaml.org.

Contributing

Contributing Guide

We wholeheartedly welcome contributors! To start, please read our Contributing Guide to familiarize yourself with our development process, including how to propose and how to start hacking on ocamlformat.

Hacking Guide

In addition to the Contributing Guide, we provide a Hacking Guide for ocamlformat developers. It contains in-depth explanation of development processes, such as running tests, releasing ocamlformat, etc.

Code of Conduct

In order to foster a welcoming and respectful community, ocamlformat has adopted the OCaml Code of Conduct.

Roadmap

Interested in the future of ocamlformat? Take a look at our Roadmap to understand our vision and planned advancements for ocamlformat.

Discussions

For conversations on ongoing development, be sure to visit the ocamlformat section of the OCaml Discuss forum.

License

ocamlformat is distributed under the terms of the MIT License. See the LICENSE file for complete details.

Acknowledgments

We gratefully acknowledge the individuals and organizations that have significantly contributed to ocamlformat.

ocamlformat owes its existance to its initial author, Josh Berdine. We also want to express our appreciation to Hugo Heuzard, Guillaume Petiot, and Jules Aguillon. Their significant contributions have been instrumental to the advancement of ocamlformat.

Moreover, our gratitude extends to Facebook, who fostered the inception of ocamlformat as part of their work on the ReasonML project. Jane Street and Tarides have also provided financial support and contributed to the ongoing development of the project.

Dependencies (5)

  1. re >= "1.10.3"
  2. ocamlformat-lib = version
  3. dune >= "2.8"
  4. csexp >= "1.4.0"
  5. ocaml >= "4.08"

Dev Dependencies (4)

  1. odoc with-doc
  2. ocamlformat-rpc-lib with-test & = version
  3. dune < "3.22" & with-test
  4. cmdliner with-test = "false" & >= "1.1.0" | with-test & >= "1.2.0"

Optional Dependencies

None

  1. ask
  2. ask-integrator
  3. autofonce
  4. autofonce_config
  5. autofonce_core
  6. autofonce_lib
  7. autofonce_m4
  8. autofonce_misc
  9. autofonce_patch
  10. autofonce_share
  11. awskit >= "0.2.0"
  12. awsm-codegen
  13. bastet < "2.0.0"
  14. bhttp
  15. bitpack_serializer
  16. brisk-reconciler
  17. CamelCase
  18. canary >= "0.0.4"
  19. cdp
  20. claudius
  21. coap
  22. coap-core
  23. coap-server-lwt
  24. diff
  25. diskuvbox < "0.2.0"
  26. dream-inertia
  27. drom
  28. drom_lib
  29. drom_toml
  30. dump_ocamlformat
  31. dune-release >= "2.3.0"
  32. dune_deps_extra
  33. ephemeral
  34. ez_cmdliner >= "0.2.0"
  35. ez_config >= "0.2.0"
  36. ez_file >= "0.2.0" & < "0.5.0"
  37. ez_hash < "0.5.3"
  38. ez_opam_file
  39. ez_search
  40. ez_subst
  41. fromager
  42. giflib
  43. guardian != "0.1.0"
  44. header-check
  45. hedgehog
  46. hegel
  47. highway
  48. hpke
  49. html_of_jsx >= "0.0.6"
  50. js_of_ocaml-webgpu >= "0.2"
  51. letters >= "0.2.0" & != "0.3.1"
  52. lunar
  53. lwt >= "6.1.3"
  54. mehari >= "0.5"
  55. melange-fest
  56. melange-fetch >= "0.2.0"
  57. melange-json >= "1.2.0"
  58. melange-radix-icons >= "0.1.0"
  59. melange-str
  60. mlx
  61. module-graph
  62. mqtt
  63. nel
  64. noCanren
  65. object
  66. ocaml-lsp-server < "1.9.0" | >= "1.28.0-506~preview"
  67. ocamlmerlin-mlx >= "0.11"
  68. ochre
  69. ocp-search
  70. ocplib_stuff >= "0.3.0"
  71. ohttp
  72. oktree
  73. opam-bin >= "0.9.5"
  74. opam_bin_lib >= "0.9.5"
  75. owi >= "0.2"
  76. parseff
  77. pgn_to_tex
  78. pidgin
  79. pidgio
  80. polars
  81. polars_async
  82. ppx_deriving_ezjsonm >= "0.5.0"
  83. ppx_deriving_jsonschema
  84. ppx_deriving_melange
  85. ppx_deriving_yaml >= "0.5.0"
  86. ppx_deriving_yamlx
  87. ppx_mixins
  88. prelude >= "0.4"
  89. primavera
  90. psmt2-frontend >= "0.3.0"
  91. query-json
  92. quickjs >= "0.2.0" & < "0.5.0"
  93. raylib >= "2.0.0" & < "2.4.2"
  94. rea < "0.2.0"
  95. react-rules-of-hooks-ppx
  96. red-black-tree
  97. scope
  98. signal
  99. sihl < "0.1.0"
  100. slugline
  101. smtml >= "0.10.0"
  102. solidity-alcotest
  103. solidity-common
  104. solidity-parser
  105. solidity-test
  106. solidity-typechecker
  107. soteria
  108. spectrum >= "0.7.0"
  109. sqids
  110. styled-ppx
  111. symex
  112. synchronizer
  113. tabr
  114. virtfs
  115. yamlx >= "0.4.0"
  116. yocaml >= "2.0.0"
  117. zanuda < "1.1.0"

Conflicts

None

Build status

Results of building ocamlformat with each compiler on check.ci.ocaml.org, run of against opam-repository 8d8d144. All results for this package.

Each result links to its build log. To keep crawlers from overloading the site, build logs require a GitHub sign-in (see ocurrent/opam-health-check). On your first log, GitHub asks you to “Authorize opam-health-check”, the OCurrent app that runs these checks; it sees only your public profile, not your repositories. The sign-in lasts 30 days.

Version OCaml 4.11 OCaml 4.14 OCaml 5.2 OCaml 5.4 OCaml 5.5
0.29.0 (this version) n/a good good good good
0.28.1 good good good good good
  • good Package successfully built
  • partial One of the dependencies failed to build
  • bad Package failed to build
  • n/a Package is not available in this environment
  • internal Internal failure