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
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions autoload/argwrap.vim
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,19 @@ function! argwrap#wrapContainer(range, container, arguments, wrapBrace, tailComm
end

call append(l:line, l:text)
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?

if l:first
norm! Jx
let l:indentation = repeat(" ", getcurpos()[2] - 1)
else
let l:line += 1
call setline(l:line, substitute(getline(l:line), "^ *", l:indentation, ""))
endif
else
let l:line += 1
silent! exec printf('%s>', l:line)
endif

if l:first && a:commaFirstIndent
let width = &l:shiftwidth
Expand Down