Stream: helpdesk (published)

Topic: ✔ indentation in vim


view this post on Zulip Rein Zustand (Nov 14 2021 at 04:33):

I'm using vim-polyglot for my vim, which uses julia-vim. When I try to automatically indent my function definition using the vim command =, I get this:

function calculate_pd_change_overall(
    data,
    shock_year = nothing,
    end_of_analysis = nothing,
    risk_free_interest_rate = nothing
  )

whereas if I use JuliaFormatter.jl (via https://github.com/kdheepak/JuliaFormatter.vim), there are no 2-spaces preceding the closing parentheses.

It is instead

function calculate_pd_change_overall(
    data,
    shock_year = nothing,
    end_of_analysis = nothing,
    risk_free_interest_rate = nothing
)

I think the latter one is more correct? How do I configure julia-vim to be like JuliaFormatter.jl?

view this post on Zulip Rein Zustand (Nov 14 2021 at 11:47):

Update: I was setting the wrong config.
This is solved by adding

let g:julia_indent_align_brackets=0

in the vimrc. Wonder why this is not the default? Should I raise an issue upstream at https://github.com/JuliaEditorSupport/julia-vim?

view this post on Zulip Sundar R (Nov 14 2021 at 14:38):

I think the latter one is more correct?

Is there a "more correct" here? afaik it's a matter of stylistic preference, and I, for example, slightly prefer the former one (the current default). The Blue style does seem to prefer the unindented closing paren, but I don't think it's so widely agreed upon that it should necessarily set the defaults.

view this post on Zulip Rein Zustand (Nov 16 2021 at 05:23):

I looked at the stdlib, found https://github.com/JuliaLang/julia/blob/47255f9fe866758472e2420e475bd174d0ba70d5/stdlib/LinearAlgebra/src/cholesky.jl#L166-L167 which is not properly indented?

view this post on Zulip Rein Zustand (Nov 16 2021 at 05:23):

Just looking for examples for which style is used in the stdlib.

view this post on Zulip Notification Bot (Nov 21 2021 at 14:15):

Rein Zustand has marked this topic as resolved.


Last updated: Nov 22 2024 at 04:41 UTC