A pipeline is always indented according to the argument it applies to.
Therefore, if it was indented like this:

@nums [
  1,
  2,
  3
]
|> Enum.map(&(&1 * 2))
|> Enum.reject(&(&1 < 5))
|> length()

I would expect it to apply to the result of "@nums [...]".

In general, Elixir code would be formatted as:

@nums [
        1,
        2,
        3
      ]

And as:

nums =
  [
    1,
    2,
    3
  ]

But we added a rule that, if the right side of operators or the last
argument of a function call is a list (or a map, or a fn, etc), we can skip
the newline and the indentation. It is a good rule for most cases, but it
leads to two different formats in cases you have a pipeline and so on.

Regareding sigils, Elixir could add rules to format its own sigils, but
they would have to be opt-in. First of all, someone can override the
built-in sigils and the formatter wouldn't know. And even if it is the same
sigil, the Elixir formatter does not change the AST by default.

-- 
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%2Bu6r4ZWae63P44DBDw_kjbzbqiYqPSDR8pvSvV2FKWjw%40mail.gmail.com.

Reply via email to