#ZLS array formatting

1 messages · Page 1 of 1 (latest)

devout goblet
#

Auto-format works really well for me, for the most part. But this is driving me a little nuts.

For reference, this is what I expect:

pub const palettes = [_]Palette{
    Palette{ .fg = rl.Color.black, .bg = rl.Color.white },
    Palette{ .fg = rl.Color.white, .bg = rl.Color.black },
    Palette{ .fg = rl.Color.dark_purple, .bg = rl.Color.orange },
    Palette{ .fg = rl.Color.orange, .bg = rl.Color.dark_purple }
};

Any way to prevent ZLS from formatting arrays in a huge line like this?

pub const palettes = [_]Palette{ Palette{ .fg = rl.Color.black, .bg = rl.Color.white }, Palette{ .fg = rl.Color.white, .bg = rl.Color.black }, Palette{ .fg = rl.Color.dark_purple, .bg = rl.Color.orange }, Palette{ .fg = rl.Color.orange, .bg = rl.Color.dark_purple } };
tulip fossil
#

this is zig fmt not zls,
just put a trailing , on the last item, works in every place where you have a comma seperated list like field, params and arrays ofc

devout goblet
#

omg yeah that does it. now it seems really obvious ahahah

thank you!

little oracle
#

Also you can do .{ instead of Palette{ in all elements, would shorten the code slighty

devout goblet
#

ooo good to know, ty!

shy nacelle
#

oh nvm im late