Skip to content

Commit 349bc9f

Browse files
committed
Always indent with only 2 spaces except when function arguments span
multiple lines. * indent with 2 spaces ``` Enum.map(list, fn outer -> Enum.map(outer, fn inner -> some() code() end) end) ``` * exceptions ``` function(arg1, arg2, arg3) ```
1 parent 92aabbd commit 349bc9f

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

elixir-smie.el

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@
240240
((and (not (smie-rule-sibling-p))
241241
(smie-rule-hanging-p))
242242
(smie-rule-parent elixir-smie-indent-basic))))
243-
243+
244244
(`(:before . "->")
245245
(cond
246246
((smie-rule-hanging-p)
@@ -275,6 +275,12 @@
275275
(t
276276
(smie-rule-parent elixir-smie-indent-basic))))))
277277

278+
(`(:before . "fn")
279+
(smie-rule-parent))
280+
281+
(`(:before . "end")
282+
(smie-rule-parent))
283+
278284
;; Closing paren on the other line
279285
(`(:before . "(")
280286
(smie-rule-parent))
@@ -284,7 +290,7 @@
284290
((smie-rule-parent-p "after" "catch" "def" "defmodule" "defp" "do" "else"
285291
"fn" "if" "rescue" "try" "unless")
286292
(smie-rule-parent elixir-smie-indent-basic))))
287-
293+
288294
(`(:after . ";")
289295
(cond
290296
((smie-rule-parent-p "if")

test/elixir-mode-indentation-test.el

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -572,24 +572,25 @@ x = do_something(
572572
:bar
573573
)")
574574

575-
(elixir-def-indentation-test indent-inside-parens/2 ()
576-
"
575+
(elixir-def-indentation-test indent-inside-parens/2
576+
(:tags '(indentation))
577+
"
577578
x = do_something(:foo,
578-
:bar)"
579-
"
579+
:bar)"
580+
"
580581
x = do_something(:foo,
581582
:bar)")
582583

583584
(elixir-def-indentation-test indent-inside-parens/3
584-
(:expected-result :failed)
585-
"
585+
(:tags '(indentation))
586+
"
586587
x = do_something(:foo, fn (arg) ->
587588
do_another(arg)
588589
end)"
589590
"
590591
x = do_something(:foo, fn (arg) ->
591-
do_another(arg)
592-
end)")
592+
do_another(arg)
593+
end)")
593594

594595
(elixir-def-indentation-test indent-lone-keyword ()
595596
"

0 commit comments

Comments
 (0)