I started exploring the solution here. This is going to need a bit more work than just moving the dot_formatter to a relative_to, as it seems the plugins and deps also use CWD.
To get to a clear solution, I am wondering in which circumstances we expect the formatter to run. Mostly I am wondering due to subdirectories and plugins. Deps already use Mix.Project.deps_paths as a root. Subdirectories use a prefix that I can probably reuse. For plugins, I hope that loadpaths will not need to change.
But if someone runs the formatter from inside the project and not at the top, what do we expect to happen? The documentation for the task says "the .formatter.exs in current directory", but you can also pass a path to one as a flag, which I am not sure would work rn because I am pretty sure the "relative_to_cwd" stuff would break.
I am going to go forward for now adding a relative_to option and trying to use it for the dot_formatter evaluation and the find_formatter_and_opts_for_file but I feel like I am missing something here. Would love to know what.