package ocamlformat

  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.

Published: 23 Apr 2024

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

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. cmdliner >= "1.1.0"
  5. ocaml >= "4.08" & < "5.4"

Dev Dependencies (5)

  1. odoc with-doc
  2. ocp-indent with-test & = "1.8.1"
  3. ocamlformat-rpc-lib with-test & = version
  4. dune < "3.22" & with-test
  5. cmdliner with-test & >= "1.2.0"

Used by (99)

  1. api-watch
  2. ask
  3. ask-integrator
  4. autofonce
  5. autofonce_config
  6. autofonce_core
  7. autofonce_lib
  8. autofonce_m4
  9. autofonce_misc
  10. autofonce_patch
  11. autofonce_share
  12. awsm-codegen
  13. bastet < "2.0.0"
  14. binsec >= "0.11.0"
  15. bitpack_serializer
  16. brisk-reconciler
  17. CamelCase
  18. canary >= "0.0.4"
  19. coap
  20. coap-core
  21. coap-server-lwt
  22. color >= "0.3.0"
  23. diff
  24. diskuvbox < "0.2.0"
  25. dream-inertia
  26. drom
  27. drom_lib
  28. drom_toml
  29. dump_ocamlformat
  30. dune-cargo-build
  31. dune_deps_extra
  32. ephemeral
  33. ez_cmdliner >= "0.2.0"
  34. ez_config >= "0.2.0"
  35. ez_file >= "0.2.0"
  36. ez_hash < "0.5.3"
  37. ez_opam_file
  38. ez_search
  39. ez_subst
  40. fromager
  41. guardian != "0.1.0"
  42. header-check
  43. html_of_jsx >= "0.0.6"
  44. js_of_ocaml-webgpu >= "0.2"
  45. letters >= "0.2.0" & != "0.3.1"
  46. lunar
  47. melange-fest
  48. melange-fetch >= "0.2.0"
  49. melange-json >= "1.2.0" & < "2.0.0"
  50. melange-radix-icons >= "0.1.0"
  51. melange-str
  52. mlx
  53. module-graph
  54. mqtt
  55. noCanren >= "0.3.0~alpha1"
  56. ocaml-lsp-server < "1.9.0" | >= "1.18.0" & < "1.21.0-4.14"
  57. ocamlmerlin-mlx >= "0.11"
  58. ocp-search
  59. ocplib_stuff >= "0.3.0"
  60. oktree
  61. opam-bin >= "0.9.5"
  62. opam_bin_lib >= "0.9.5"
  63. owi >= "0.2"
  64. parseff < "0.2.0"
  65. passage < "0.3.2"
  66. polars
  67. polars_async
  68. pp >= "2.0.0"
  69. ppx_deriving_jsonschema
  70. ppxlib >= "0.34.0" & < "0.38.0~5.5preview"
  71. prelude >= "0.4"
  72. primavera
  73. psmt2-frontend >= "0.3.0"
  74. query-json
  75. quickjs >= "0.2.0"
  76. rea < "0.2.0"
  77. react-rules-of-hooks-ppx
  78. red-black-tree
  79. rust-staticlib-gen
  80. scope
  81. signal
  82. sihl < "0.1.0"
  83. slipshow = "0.0.33"
  84. smtml >= "0.10.0" & < "0.24.0"
  85. solidity-alcotest
  86. solidity-common
  87. solidity-parser
  88. solidity-test
  89. solidity-typechecker
  90. spectrum >= "0.7.0"
  91. spotify_ml
  92. sqids
  93. styled-ppx
  94. synchronizer
  95. tabr
  96. tezt = "4.2.0"
  97. virtfs
  98. yocaml >= "2.0.0"
  99. zanuda < "2.0.0"

Conflicts

None