1

I have OCaml project and in vendor folder I have some libraries that are not of my own, I don't want to run ocamlformat on them I tried this

# .ocamlformat
profile = default
version = 0.24.1
# .ocamlformat-ignore
vendor/*

But when I run dune build @fmt I see a lot of errors regarding the vendor folder

(cd _build/default && /home/geckos/.opam/coq-of-solidity/bin/ocamlformat --intf vendor/ocaml-solidity/src/solidity-typechecker/solidity_typechecker.mli) > _build/default/vendor/ocaml-solidity/src/solidity-typechecker/.formatted/solidity_typechecker.mli
ocamlformat: Error while parsing /home/geckos/code/coq-of-solidity/_build/default/vendor/ocaml-solidity/.ocamlformat:
             Project should be formatted using ocamlformat version "0.15.0", but the installed version is "0.24.1"
             For option "align-cases": This option has been removed in version 0.22.
             For option "align-constructors-decl": This option has been removed in version 0.22.
             For option "align-variants-decl": This option has been removed in version 0.22.
             For option "let-open": This option has been removed in version 0.17. Concrete syntax will now always be preserved.
geckos
  • 5,687
  • 1
  • 41
  • 53

2 Answers2

2

Having vendor/** in your .ocamlformat-ignore file should fix your issue. No need to have a line for each sublevel of your vendor directory.

gpetiot
  • 21
  • 2
0

There's an FAQ entry explaining this in the documentation:

It is possible to disable OCamlFormat for the files of a directory by having an .ocamlformat file containing disable in this directory, or listing the files to ignore in an .ocamlformat-ignore file.

For now it is not possible to recursively ignore all subdirectories and files from a parent directory, you need to list all the descendants of the directory to ignore them, e.g.:

dir/*
dir/*/*
dir/*/*/*

It is also possible to add an .ocamlformat-ignore file containing * in every directory that needs to be ignored.

Edit: This FAQ entry is apparently outdated. It should also be possible to use vendor/"", as @gpetiot points out in the other answer. As the current maintainer he should know. (I've also submitted a PR to update the documentation)

glennsl
  • 28,186
  • 12
  • 57
  • 75
  • Thanks glenssi It seems to me that the problem is that the vendor project also uses ocamlformat but in another version and the error is because it's trying to parse the .ocamlformat files inside the vendor folder and not about the .ml files, I tried multiple combinations of `dir/*/*/*` I will try `vendor/**` – geckos Jan 08 '23 at 03:29