domluna / JuliaFormatter.jl

An opinionated code formatter for Julia. Plot twist - the opinion is your own.
https://domluna.github.io/JuliaFormatter.jl/dev/
MIT License
579 stars 69 forks source link

Inconsistent argument aligning #60

Closed odow closed 5 years ago

odow commented 5 years ago

I took a pass over my SDDP.jl library (odow/SDDP.jl#256) and for the most part, it worked great! SDDP.jl should be a reasonably good test-case because it includes quite a few JuMP models with weird macro syntax.

Here's one of the things that came out of it:

s = """
function write_subproblem_to_file(
        node::Node, filename::String;
        format::Symbol=:both, throw_error::Bool = false)
end
"""
print(JuliaFormatter.format_text(s))

# output 

function write_subproblem_to_file(
    node::Node,
    filename::String;
    format::Symbol = :both, throw_error::Bool = false
) end

# expected

function write_subproblem_to_file(
    node::Node,
    filename::String;
    format::Symbol = :both, 
    throw_error::Bool = false
) end
domluna commented 5 years ago

This works as intended but kwargs arguments seem to be a case where we'd want to force nesting if other arguments are nested.