Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ocp-indent as a formatter #306

Merged
merged 2 commits into from
Sep 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ The format is based on [Keep a Changelog].
* New user option `apheleia-skip-functions`, like
`apheleia-inhibit-functions` but for skipping a formatter run even
when `apheleia-mode` is generally enabled ([#317]).
* [`ocp-indent`](https://github.com/OCamlPro/ocp-indent) for
[Ocaml](https://ocaml.org/) ([#306]).

### Formatters
* [`typstyle`](https://github.com/Enter-tainer/typstyle) for
Expand Down
1 change: 1 addition & 0 deletions apheleia-formatters.el
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
(nixfmt . ("nixfmt"))
(ocamlformat . ("ocamlformat" "-" "--name" filepath
"--enable-outside-detected-project"))
(ocp-indent . ("ocp-indent"))
(ormolu . ("ormolu"))
(perltidy . ("perltidy" "--quiet" "--standard-error-output"
(apheleia-formatters-indent "-t" "-i")
Expand Down
5 changes: 5 additions & 0 deletions test/formatters/installers/ocp-indent.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apt-get install -y opam

opam init -n --disable-sandboxing --root /opt/ocp-indent
opam install ocp-indent -y --root /opt/ocp-indent
ln -s /opt/ocp-indent/default/bin/ocp-indent /usr/local/bin/
35 changes: 35 additions & 0 deletions test/formatters/samplecode/ocp-indent/in.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
(* https://github.com/OCamlPro/ocp-indent/blob/master/tests/failing/list_of_funs.ml *)

let f x =
(fun x -> x [ (fun () -> 3) ;
(fun () -> 4) ])

let f x = (fun x -> x [ (fun () -> 3) ;
(fun () -> 4) ])

let f x =
x [ (fun () -> 3) ;
(fun () -> 4) ]

let f x =
[ (fun () -> 3) ;
(fun () -> 4) ]

let f x =
(fun x -> x [ (fun () ->
3) ;
(fun () -> 4) ])

let f x = (fun x -> x [ (fun () ->
3) ;
(fun () -> 4) ])

let f x =
x [ (fun () ->
3) ;
(fun () -> 4) ]

let f x =
[ (fun () ->
3) ;
(fun () -> 4) ]
35 changes: 35 additions & 0 deletions test/formatters/samplecode/ocp-indent/out.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
(* https://github.com/OCamlPro/ocp-indent/blob/master/tests/failing/list_of_funs.ml *)

let f x =
(fun x -> x [ (fun () -> 3) ;
(fun () -> 4) ])

let f x = (fun x -> x [ (fun () -> 3) ;
(fun () -> 4) ])

let f x =
x [ (fun () -> 3) ;
(fun () -> 4) ]

let f x =
[ (fun () -> 3) ;
(fun () -> 4) ]

let f x =
(fun x -> x [ (fun () ->
3) ;
(fun () -> 4) ])

let f x = (fun x -> x [ (fun () ->
3) ;
(fun () -> 4) ])

let f x =
x [ (fun () ->
3) ;
(fun () -> 4) ]

let f x =
[ (fun () ->
3) ;
(fun () -> 4) ]