aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md2
-rw-r--r--apheleia-formatters.el1
-rw-r--r--test/formatters/installers/ocp-indent.bash5
-rw-r--r--test/formatters/samplecode/ocp-indent/in.ml35
-rw-r--r--test/formatters/samplecode/ocp-indent/out.ml35
5 files changed, 78 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e3235c4..42a478a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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
diff --git a/apheleia-formatters.el b/apheleia-formatters.el
index b8c17ab..5578398 100644
--- a/apheleia-formatters.el
+++ b/apheleia-formatters.el
@@ -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")
diff --git a/test/formatters/installers/ocp-indent.bash b/test/formatters/installers/ocp-indent.bash
new file mode 100644
index 0000000..0e449f2
--- /dev/null
+++ b/test/formatters/installers/ocp-indent.bash
@@ -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/
diff --git a/test/formatters/samplecode/ocp-indent/in.ml b/test/formatters/samplecode/ocp-indent/in.ml
new file mode 100644
index 0000000..d647068
--- /dev/null
+++ b/test/formatters/samplecode/ocp-indent/in.ml
@@ -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) ]
diff --git a/test/formatters/samplecode/ocp-indent/out.ml b/test/formatters/samplecode/ocp-indent/out.ml
new file mode 100644
index 0000000..dddb26b
--- /dev/null
+++ b/test/formatters/samplecode/ocp-indent/out.ml
@@ -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) ]