ols
ols copied to clipboard
[odinfmt idea] Better formatting for procs with a single struct initializer parameter
In Sokol libraries it's very common to pass a single "_Desc
" struct with all parameters, instead of passing them individually.
For example:
make_buffer :: proc(#by_ptr desc: Buffer_Desc) -> Buffer ---
Which when called is formatted into something like this:
model_vertex_buf := sg.make_buffer(
{
type = .VERTEXBUFFER,
usage = .IMMUTABLE,
size = u64(len(vertices) * size_of(vertices[0])),
data = sg_range_slice(vertices),
},
)
But it would be nicer if it was formatted like this:
model_vertex_buf := sg.make_buffer({
type = .VERTEXBUFFER,
usage = .IMMUTABLE,
size = u64(len(vertices) * size_of(vertices[0])),
data = sg_range_slice(vertices),
})
In case this would add unnecessary complexity to the formatter or just isn't something you want, feel free to close this issue. It's just a small idea...
Yeah seems like a better option. Can always start just doing that specific format when there is only one argument with comp literal. Not sure how nice it would look if there are more arguments.
Yeah I think it would totally make sense to limit it to procs with only one parameter