[Proposal] Disable formatter only for some part of code

68 views
Skip to first unread message

adonig

unread,
Apr 21, 2023, 4:53:19 PM4/21/23
to elixir-lang-core
Before the age of great tooling people were creative when formatting their code and found ways to use formatting to help readers visualize what the code does. A formatter can't be that creative like a human (yet) but it would be beneficial if there's a way to disable the formatter for some parts of the code, for example like this:

shape = [
    # formatter: off
    {2, 1},
    {2, 2},
    {2, 3}, {3, 3}
    # formatter: on
]

Jon Rowe

unread,
Apr 21, 2023, 5:18:32 PM4/21/23
to Elixir Lang Core
One of the benefits of the formatter is preventing arguments over syntax, thus it is only minimally configurable, you are free to not use it if you wish to be creative in a non standard way.
--
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.

Austin Ziegler

unread,
Apr 21, 2023, 5:57:23 PM4/21/23
to elixir-l...@googlegroups.com
Additionally, if the visual shape of something is important for understanding it, it may be better to have that in an external file *not* covered by Elixir and compiled into the application as an attribute.

One thing that *could* be helpful is if `Path.wildcard/2` accepted negative entries, but that could get messy (it would also be possible to exclude a whole file by running `Path.wildcard/2` over your `input` patterns in `.formatter.exs` and then removing the file(s) you want to exclude).

Preventing *editor*-based formatters from doing changes like this is a different exercise entirely.

-a



--
Reply all
Reply to author
Forward
0 new messages