Inconsistent map-type brackets/parens indentation behavior
yowcow opened this issue · 3 comments
Current indentation of maps:
M1 = #{
},
M2 = #{
k1 => v1
},
doesn't seem quite right in 2 cases, when a map is:
- in a list
- a function return value
Examples:
L = [
(
),
[
],
{
},
<<
>>,
#{
},
#{
k => v
}
],
a_func() ->
#{
}.
a_func() ->
#{
k => v
}.
For consistency, maps look so much better when indented as something similar to:
M1 = #{
},
M2 = #{
k => v
},
so that maps align better with other types of opening and closing brackets/parens in a list or a function:
L = [
(
),
[
],
{
},
<<
>>,
#{
},
#{
k => v
}
],
a_func() ->
#{
}.
a_func() ->
#{
k => v
}.
Hi @yowcow,
Thank you for the issue and your PR, I looked at both of them.
The method I generally follow when deciding how something should be indented is that I look at how the Erlang mode of Emacs indents it and try to replicate that in vim-erlang-runtime. (Emacs's Erlang mode is shipped with Erlang/OTP itself, and most of the original developers of Erlang use Emacs, thus that is the de facto standard for indenting Erlang code.)
In this particular case, Emacs indents maps the way you propose. Since vim-erlang-runtime already indents records the "correct" way, I think this makes us very lucky now and we only need to add one letter to the indentation script to make maps behave that way.
Could you look at my commit 939f3f9? I copied your new tests too, but re-indented them.