Merge branch 'master' of https://github.com/FooSoft/vim-argwrap
This commit is contained in:
commit
03a29b3e6c
@ -156,9 +156,10 @@ function! argwrap#extractContainer(range)
|
|||||||
return {'indent': l:indent, 'prefix': l:prefix, 'suffix': l:suffix}
|
return {'indent': l:indent, 'prefix': l:prefix, 'suffix': l:suffix}
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! argwrap#wrapContainer(range, container, arguments, wrapBrace, tailComma, linePrefix, commaFirst)
|
function! argwrap#wrapContainer(range, container, arguments, wrapBrace, tailComma, tailCommaBraces, linePrefix, commaFirst)
|
||||||
let l:argCount = len(a:arguments)
|
let l:argCount = len(a:arguments)
|
||||||
let l:line = a:range.lineStart
|
let l:line = a:range.lineStart
|
||||||
|
let l:prefix = a:container.prefix[len(a:container.prefix) - 1]
|
||||||
|
|
||||||
call setline(l:line, a:container.indent . a:container.prefix)
|
call setline(l:line, a:container.indent . a:container.prefix)
|
||||||
|
|
||||||
@ -175,7 +176,7 @@ function! argwrap#wrapContainer(range, container, arguments, wrapBrace, tailComm
|
|||||||
let l:text .= a:arguments[l:index]
|
let l:text .= a:arguments[l:index]
|
||||||
else
|
else
|
||||||
let l:text .= a:container.indent . a:linePrefix . a:arguments[l:index]
|
let l:text .= a:container.indent . a:linePrefix . a:arguments[l:index]
|
||||||
if !l:last || a:tailComma
|
if !l:last || a:tailComma || a:tailCommaBraces =~ l:prefix
|
||||||
let l:text .= ','
|
let l:text .= ','
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -226,6 +227,7 @@ function! argwrap#toggle()
|
|||||||
let l:linePrefix = argwrap#getSetting('line_prefix', '')
|
let l:linePrefix = argwrap#getSetting('line_prefix', '')
|
||||||
let l:padded = argwrap#getSetting('padded_braces', '')
|
let l:padded = argwrap#getSetting('padded_braces', '')
|
||||||
let l:tailComma = argwrap#getSetting('tail_comma', 0)
|
let l:tailComma = argwrap#getSetting('tail_comma', 0)
|
||||||
|
let l:tailCommaBraces = argwrap#getSetting('tail_comma_braces', '')
|
||||||
let l:wrapBrace = argwrap#getSetting('wrap_closing_brace', 1)
|
let l:wrapBrace = argwrap#getSetting('wrap_closing_brace', 1)
|
||||||
let l:commaFirst = argwrap#getSetting('comma_first', 0)
|
let l:commaFirst = argwrap#getSetting('comma_first', 0)
|
||||||
|
|
||||||
@ -242,7 +244,7 @@ function! argwrap#toggle()
|
|||||||
|
|
||||||
let l:container = argwrap#extractContainer(l:range)
|
let l:container = argwrap#extractContainer(l:range)
|
||||||
if l:range.lineStart == l:range.lineEnd
|
if l:range.lineStart == l:range.lineEnd
|
||||||
call argwrap#wrapContainer(l:range, l:container, l:arguments, l:wrapBrace, l:tailComma, l:linePrefix, l:commaFirst)
|
call argwrap#wrapContainer(l:range, l:container, l:arguments, l:wrapBrace, l:tailComma, l:tailCommaBraces, l:linePrefix, l:commaFirst)
|
||||||
else
|
else
|
||||||
call argwrap#unwrapContainer(l:range, l:container, l:arguments, l:padded)
|
call argwrap#unwrapContainer(l:range, l:container, l:arguments, l:padded)
|
||||||
endif
|
endif
|
||||||
|
@ -73,7 +73,7 @@ file basis using `ftplugin` or `autocmd`. For example, the `argwrap_tail_comma`
|
|||||||
<
|
<
|
||||||
Padding can be specified for multiple brace types ()
|
Padding can be specified for multiple brace types ()
|
||||||
* argwrap_tail_comma
|
* argwrap_tail_comma
|
||||||
Specifies if the closing brace should be preceded with a comma when wrapping lines.
|
Specifies if any closing brace should be preceded with a comma when wrapping lines.
|
||||||
Tail comma disabled (default)
|
Tail comma disabled (default)
|
||||||
>
|
>
|
||||||
Foo(
|
Foo(
|
||||||
@ -90,6 +90,24 @@ file basis using `ftplugin` or `autocmd`. For example, the `argwrap_tail_comma`
|
|||||||
wubble,
|
wubble,
|
||||||
)
|
)
|
||||||
<
|
<
|
||||||
|
* argwrap_tail_comma_braces
|
||||||
|
Specifies which closing brace should be preceded with a comma when wrapping lines.
|
||||||
|
Tail comma disabled (default)
|
||||||
|
>
|
||||||
|
Foo(
|
||||||
|
wibble,
|
||||||
|
wobble,
|
||||||
|
wubble
|
||||||
|
)
|
||||||
|
<
|
||||||
|
Tail comma enabled for square brackets ()
|
||||||
|
>
|
||||||
|
r = [
|
||||||
|
3,
|
||||||
|
5,
|
||||||
|
8,
|
||||||
|
]
|
||||||
|
<
|
||||||
* argwrap_wrap_closing_brace
|
* argwrap_wrap_closing_brace
|
||||||
Specifies if the closing brace should be wrapped to a new line.
|
Specifies if the closing brace should be wrapped to a new line.
|
||||||
Brace wrapping enabled (default)
|
Brace wrapping enabled (default)
|
||||||
|
Loading…
Reference in New Issue
Block a user