> So I would like to request that there be a function to get the formatter options (and as-of Elixir 1.13 formatter as well) relative to a passed in directory. If we can settle on an approach I'd be willing to create a PR for this.
Maybe I am oversimplifying this but can we: 1. Accept cwd as an option (which defaults to File.cwd) 2. Make sure that all the path lookups what we do have a Path.join(cwd, path) ? In any case, a PR to address this is very welcome, regardless of the approach, since it is important to Elixir LS. On Thu, Dec 16, 2021 at 6:42 PM Jason Axelson <jason.axel...@gmail.com> wrote: > Hi all, > > While working on ElixirLS we cannot use the normal `mix format` for a few > reasons: > - We want to provide the results of the formatting as Language Server > Protocol edits which allows editors to undo the formatting > - We want to format quickly without paying the cost of the BEAM startup > time > > Therefore up until now we've been formatting using Code.format_string!/2 > and using Mix.Tasks.Format.formatter_opts_for_file/2 to find the formatter > options, however that suffers from a major problem for us, the result of > Mix.Tasks.Format.formatter_opts_for_file/2 depends on the value of the > current working directory (i.e. File.cwd/0), and because of the current > architecture of ElixirLS the current working directory is not stable and we > cannot control it directly (the current working directory changes as elixir > code is compiled). > > So I would like to request that there be a function to get the formatter > options (and as-of Elixir 1.13 formatter as well) relative to a passed in > directory. If we can settle on an approach I'd be willing to create a PR > for this. > > I'm also open to alternative suggestions (especially ones that take into > consideration the fact that we cannot control the current working > directory). If it were possible I would love if I could give an individual > Elixir process its own file server with its own current working directory. > However I'm not sure that that is possible in the BEAM. The only mentions > of the file server that I've been able to find in the Erlang docs are in > https://www.erlang.org/doc/man/file.html and the file server is only > referenced indirectly. > > Thanks, > Jason > > -- > You received this message because you are subscribed to the Google Groups > "elixir-lang-core" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to elixir-lang-core+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/elixir-lang-core/CAHMz6kxfAwzFE8TZzrCSOtmaGLoxZQqUqX55iS9u2S%3DU6EeB3Q%40mail.gmail.com > <https://groups.google.com/d/msgid/elixir-lang-core/CAHMz6kxfAwzFE8TZzrCSOtmaGLoxZQqUqX55iS9u2S%3DU6EeB3Q%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "elixir-lang-core" group. To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-core+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4%2BkK%2BoNJjysABQBfkCyL8jtHcr1Pr8oK1sjiBEtUi6hfA%40mail.gmail.com.