Skip to content
This repository was archived by the owner on Dec 26, 2023. It is now read-only.

Add option to start list on same line #26

Closed
wants to merge 1 commit into from
Closed

Conversation

yochem
Copy link

@yochem yochem commented Oct 19, 2020

Description:
This commit adds the option to start a list on the same line, as
proposed in issue #8. By this, a wrapped list would become:

void foo(var1,
         var2,
         var3)

instead of:

void foo(
    var1,
    var2,
    var3
)

For now, the option is implemented using

let g:argwrap_wrap_closing_brace

The configuration can be extended to see this option as separate, for example let g:argwrap_wrap_braces

Warning!
It assumes the indentation is done with spaces instead of tabs

Relevant issue: #8 (#8)

Description:
This commit adds the option to start a list on the same line, as
proposed in issue FooSoft#8. By this, a wrapped list would become:

    void foo(var1,
             var2,
             var3)

instead of:

    void foo(
        var1,
        var2,
        var3
    )

For now, the option is implemented using

    let g:argwrap_wrap_closing_brace = 0

The configuration can be extended to see this option as seperate.

Warning!
It assumes the indentation is done with spaces instead of tabs

Relevant issue: FooSoft#8 (FooSoft#8)
let l:line += 1
silent! exec printf('%s>', l:line)

if !a:wrapBrace
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if !a:wrapBrace
if !a:wrapBrace && !&expandtab

Disable the feature if the expandtab is set.
Otherwise you would have to decide which are the rules: align all parameters to the next tab position ? Should the first one be aligned too ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I don't know exactly what you mean, but when I add the && !expandtab, this behaviour occurs on func(1, 2. 3):

# with expandtab off (the behaviour we wish)
func(1,
     2,
     3)

# with expandtab on (not someting we want)
func(
    1,
    2,
    3)

I think in both cases (expandtab on or off), the first argument wrap is desired, right? Or do you think other behaviour is desired when expandtab is on?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I meant is since your feature only work with spaces, when using tabs it should be disabled.
So that the previous behavior is preserved.
But I never used this kind of alignment because I think it's defeat the point.
IMO the main reasons to wrap are:

  • To avoid long lines: if the function name is long and the parameters are long too, string for examples, then it defeat the purpose
  • To avoid messy diffs (modifying one line should only print one line in the diff): with this kind of alignment to add a new parameter you must first modify the previous one

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I get your points. I'll close this pull-request for now. Thank you for the clarity!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For python, I never use tab, only use space.
I like

void foo(var1,
         var2,
         var3)

Any problem with this setting? Why do you close it?

@yochem yochem closed this Oct 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants