Hi José, Indeed Path.relative_to_cwd does return relative paths unchanged, so it appears I was not looking closely enough at the code. So the problem is indeed that the wrong .formatter.exs is chosen. Looking more closely at the code it appears that there are a number of operations that depend on the current working directory global state.
-Jason On Mon, Nov 16, 2020 at 8:43 AM José Valim <[email protected]> wrote: > Hi Jason! > > * if you give it a relative path, then I think the relative_to_cwd will > return unchanged. Have you tried it out? > > * however, I wonder if the biggest issue is not picking up the file... but > rather choosing which .formatters.exs to use? > > On Mon, Nov 16, 2020 at 7:35 PM Jason Axelson <[email protected]> > wrote: > >> Hi, >> >> For ElixirLS (with our current architecture) we need to support >> formatting of a file with varying CWD. So I'd like to propose a change to >> `Mix.Tasks.Format.formatter_opts_for_file/2` to support not relying on the >> current working directory. This is the line that would be changed: >> >> >> https://github.com/elixir-lang/elixir/blob/36d12b4bd4d26533c216e935903206cc3502200f/lib/mix/lib/mix/tasks/format.ex#L162 >> >> My first thought on how to change it is to pass a directory as an option, >> say `relative_to`. So if `:relative_to` is passed as an option then the >> formatter options are found relative to that file, but if it is not passed >> then the current behavior of using the CWD as the `relative_to` path would >> be kept. >> >> I'm open to other approaches as well. >> >> 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 [email protected]. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/elixir-lang-core/CAHMz6kzW8BHiELiEYjZT3Y3ky-9gRhjJp0REeHmj%3DLH138p9GA%40mail.gmail.com >> <https://groups.google.com/d/msgid/elixir-lang-core/CAHMz6kzW8BHiELiEYjZT3Y3ky-9gRhjJp0REeHmj%3DLH138p9GA%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 [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4KqzeLABsKL632vQ7aj7rqMycpQ4o0a1H-OV1qmYo1%3DsA%40mail.gmail.com > <https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4KqzeLABsKL632vQ7aj7rqMycpQ4o0a1H-OV1qmYo1%3DsA%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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAHMz6kwgyftNO9MnQm8zkgY84FtE%2BNgQFRJtRY-1e6jubjHCHA%40mail.gmail.com.
