gleam-lang / gleam-mode

🐙 Gleam support for Emacs
Apache License 2.0
82 stars 23 forks source link

Fix indentation for pipelines inside function arguments and lists #28

Closed rechsteiner closed 4 months ago

rechsteiner commented 4 months ago

Updated the indentation rules to indent pipelines by one level if the initial argument is inside a list or function arguments, which seems to match the behavior of gleam format.

Before:

fn main() {
  let list = [
    1
    |> io.debug
    |> io.debug,
    2,
    3,
  ]
  let arguments =
    dict.new()
    |> dict.insert(
      "Key",
      "Value"
      |> io.debug
      |> io.debug,
    )
}

After:

fn main() {
  let list = [
    1
      |> io.debug
      |> io.debug,
    2,
    3,
  ]
  let arguments =
    dict.new()
    |> dict.insert(
      "Key",
      "Value"
        |> io.debug
        |> io.debug,
    )
}
rechsteiner commented 4 months ago

Updated with a scenario I had missed. Looks like it should only indent if the expressions are inside lists with multiple elements, or function with multiple arguments, otherwise it should indent like normal.

J3RN commented 4 months ago

Looks good, thanks for your contribution! :sparkles: