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.

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"

  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. bitpack_serializer
  15. brisk-reconciler
  16. CamelCase
  17. canary >= "0.0.4"
  18. claudius
  19. coap
  20. coap-core
  21. coap-server-lwt
  22. diff
  23. diskuvbox < "0.2.0"
  24. dream-inertia
  25. drom
  26. drom_lib
  27. drom_toml
  28. dump_ocamlformat
  29. dune_deps_extra
  30. ephemeral
  31. ez_cmdliner >= "0.2.0"
  32. ez_config >= "0.2.0"
  33. ez_file >= "0.2.0" & < "0.5.0"
  34. ez_hash < "0.5.3"
  35. ez_opam_file
  36. ez_search
  37. ez_subst
  38. fromager
  39. giflib
  40. guardian != "0.1.0"
  41. header-check
  42. hedgehog
  43. hegel
  44. html_of_jsx >= "0.0.6"
  45. js_of_ocaml-webgpu >= "0.2"
  46. letters >= "0.2.0" & != "0.3.1"
  47. lunar
  48. melange-fest
  49. melange-fetch >= "0.2.0"
  50. melange-json >= "1.2.0"
  51. melange-radix-icons >= "0.1.0"
  52. melange-str
  53. mlx
  54. module-graph
  55. mqtt
  56. nel
  57. noCanren
  58. object
  59. ocaml-lsp-server < "1.9.0"
  60. ocamlmerlin-mlx >= "0.11"
  61. ochre
  62. ocp-search
  63. ocplib_stuff >= "0.3.0"
  64. oktree
  65. opam-bin >= "0.9.5"
  66. opam_bin_lib >= "0.9.5"
  67. owi >= "0.2"
  68. parseff
  69. pgn_to_tex
  70. pidgin
  71. polars
  72. polars_async
  73. ppx_deriving_jsonschema
  74. ppx_deriving_melange
  75. ppx_mixins
  76. prelude >= "0.4"
  77. primavera
  78. psmt2-frontend >= "0.3.0"
  79. query-json
  80. quickjs >= "0.2.0" & < "0.5.1"
  81. raylib >= "2.0.0"
  82. rea < "0.2.0"
  83. react-rules-of-hooks-ppx
  84. red-black-tree
  85. scope
  86. signal
  87. sihl < "0.1.0"
  88. slugline
  89. smtml >= "0.10.0"
  90. solidity-alcotest
  91. solidity-common
  92. solidity-parser
  93. solidity-test
  94. solidity-typechecker
  95. soteria
  96. spectrum >= "0.7.0"
  97. sqids
  98. styled-ppx
  99. symex
  100. synchronizer
  101. tabr
  102. virtfs
  103. yocaml >= "2.0.0"
  104. zanuda < "1.1.0"

Conflicts

None