JuliaFormatter.jl icon indicating copy to clipboard operation
JuliaFormatter.jl copied to clipboard

formatting multi-line matrices

Open lmiq opened this issue 2 years ago • 3 comments

One cool thing about Julia is that we can write a matrix as:


R = @SMatrix[ cosθ  -sinθ 
              sinθ   cosθ ]

However, the JuliaFormatter keeps transforming that to:

R = @SMatrix[cosθ -sinθ
    sinθ cosθ]

Maybe there is an easy fix?

lmiq avatar Jan 27 '23 17:01 lmiq

what are the config file/options you're using

domluna avatar Jan 27 '23 18:01 domluna

I'm using the default options shipped with VSCode and the Julia extension. I'm trying to check that, but for now I can't find any option.

lmiq avatar Jan 27 '23 18:01 lmiq

the default style that comes with vscode is MinimalStyle which keeps the lines where they are as much as possible but the indent is based on indent of X (default 4 spaces). If you want the indent to align to the opening (, {, [ then I suggest you try out YASStyle or SciMLStyle and see if that works better for you.

It's possible MinimalStyle will adopt an adaptive indent but that's probably quite a bit of work

domluna avatar Feb 18 '23 18:02 domluna