Actually I seem to recall bringing this up with Drogan a few months ago and that there is no way to perfectly preserve the original formatting converting a parsed file’s AST back to string so I have to find a way forward with patch_string
- Brian On Sun, Jul 21, 2024 at 9:56 AM Brian Cardarella <bcardare...@gmail.com> wrote: > I've run across too many people that have `mix format` as part of their > editor workflow. PRs that include massive reformats. It doesn't happen > often but it happens. > > > - Brian > > > On Sun, Jul 21, 2024 at 9:55 AM José Valim <jose.va...@dashbit.co> wrote: > >> The formatter is opt-in. Elixir does not call "mix format" for you. >> >> On Sun, Jul 21, 2024 at 10:50 AM Brian Cardarella <bcardare...@gmail.com> >> wrote: >> >>> You're correct that I'm probably coming at this from the wrong end. In >>> lieu of not getting Sourceror to accept opting out of the formatter I was >>> searching for ways to avoid the formatter from doing anything. >>> >>> As an aside, I realize the ship has sailed on this but I do wish the >>> formatter was opt-in by design. Iteratively build your formatting >>> preferences rather than default being anything at all. A single LOC to have >>> the current settings, but still opt-in >>> >>> - Brian >>> >>> >>> On Sun, Jul 21, 2024 at 9:45 AM José Valim <jose.va...@dashbit.co> >>> wrote: >>> >>>> I think there is some confusion happening here. >>>> >>>> 1. I don't see a reason to allow mix format to be a no-op? If you don't >>>> want to run the formatter, you can simply not run "mix format". >>>> >>>> 2. On the other hand, I don't think turning off the formatter will >>>> address Sourceror. I believe it uses the formatting APIs to stitch the code >>>> back together, regardless of mix format. >>>> >>>> In other words, I don't think the issue you have is mix format. It is >>>> with whatever tool that is invoking it. >>>> >>>> On Sun, Jul 21, 2024 at 10:41 AM Brian Cardarella < >>>> bcardare...@gmail.com> wrote: >>>> >>>>> Yes, I know that Sourceror has `patch_string` but that doesn't solve >>>>> all the problems I'm tackling. >>>>> >>>>> On Sunday, July 21, 2024 at 9:40:42 AM UTC-4 Brian Cardarella wrote: >>>>> >>>>>> I get that this would work but that feels hacky to me. Would you >>>>>> accept a PR to provides an opt-out option? Also, why does `mix format` >>>>>> format anything at all if `.formatter` isn't defined? I would have >>>>>> expected >>>>>> that to be no-op. >>>>>> >>>>>> My use cases: >>>>>> >>>>>> 1. I don't like auto-formatters. We don't need to debate the merits >>>>>> of this, just my preference >>>>>> 2. Sourceror forces everything through the formatter. When converting >>>>>> quoted back to strings despite all of the indentation information being >>>>>> included in the AST nodes the formatter is still run. I'd much prefer if >>>>>> the project itself opts out of the formatter that this doesn't happen and >>>>>> re-format entire files on someone. >>>>>> >>>>>> On Sunday, July 21, 2024 at 9:36:27 AM UTC-4 José Valim wrote: >>>>>> >>>>>>> You can probably change its inputs in .formatter.exs to point to a >>>>>>> directory that does not exist. >>>>>>> >>>>>>> On Sun, Jul 21, 2024 at 10:34 AM Brian Cardarella < >>>>>>> bcard...@gmail.com> wrote: >>>>>>> >>>>>>>> I don't see it in the docs, is there a way to turn off formatting >>>>>>>> entirely so if `mix format` is run it just turns into a no-op? >>>>>>>> >>>>>>>> -- >>>>>>>> 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-co...@googlegroups.com. >>>>>>>> To view this discussion on the web visit >>>>>>>> https://groups.google.com/d/msgid/elixir-lang-core/7ebc1f83-666a-4f5c-b9c5-f9fd04224d3bn%40googlegroups.com >>>>>>>> <https://groups.google.com/d/msgid/elixir-lang-core/7ebc1f83-666a-4f5c-b9c5-f9fd04224d3bn%40googlegroups.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/0004d4c0-5aa1-4e68-ae35-9d1f54e30343n%40googlegroups.com >>>>> <https://groups.google.com/d/msgid/elixir-lang-core/0004d4c0-5aa1-4e68-ae35-9d1f54e30343n%40googlegroups.com?utm_medium=email&utm_source=footer> >>>>> . >>>>> >>>> -- >>>> You received this message because you are subscribed to a topic in the >>>> Google Groups "elixir-lang-core" group. >>>> To unsubscribe from this topic, visit >>>> https://groups.google.com/d/topic/elixir-lang-core/SYdxYLcsirM/unsubscribe >>>> . >>>> To unsubscribe from this group and all its topics, 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/CAGnRm4K1JvbNyobyp2mJ3v%2BEgzn4pPriRQHg5ZzQ%2Bfwde32yJw%40mail.gmail.com >>>> <https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4K1JvbNyobyp2mJ3v%2BEgzn4pPriRQHg5ZzQ%2Bfwde32yJw%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/CADtMk1gc4gLpWWsXowJBzNp_t45%2Bx0NeLNQ5_U1AYGKexd5%3DUw%40mail.gmail.com >>> <https://groups.google.com/d/msgid/elixir-lang-core/CADtMk1gc4gLpWWsXowJBzNp_t45%2Bx0NeLNQ5_U1AYGKexd5%3DUw%40mail.gmail.com?utm_medium=email&utm_source=footer> >>> . >>> >> -- >> You received this message because you are subscribed to a topic in the >> Google Groups "elixir-lang-core" group. >> To unsubscribe from this topic, visit >> https://groups.google.com/d/topic/elixir-lang-core/SYdxYLcsirM/unsubscribe >> . >> To unsubscribe from this group and all its topics, 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/CAGnRm4Jnf_gOjX%2BPFvOiW-sS10dHSafg2e20-HXyTQrubjy%3DwA%40mail.gmail.com >> <https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4Jnf_gOjX%2BPFvOiW-sS10dHSafg2e20-HXyTQrubjy%3DwA%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/CADtMk1ja%2BjCQJVzh%2BbZTOcxzokLieCXPe5QESqeq7Epd7HxwBw%40mail.gmail.com.