Add new setting: argwrap_tail_comma_braces
This commit is contained in:
parent
112a28c888
commit
9beff4da68
26
README.md
26
README.md
@ -77,7 +77,7 @@ file basis using `ftplugin` or `autocmd`. For example, the `argwrap_tail_comma`
|
|||||||
|
|
||||||
* **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)*
|
||||||
|
|
||||||
@ -99,6 +99,30 @@ file basis using `ftplugin` or `autocmd`. For example, the `argwrap_tail_comma`
|
|||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
* **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 only (`let g:argwrap_tail_comma_braces = '['`)*
|
||||||
|
|
||||||
|
```
|
||||||
|
r = [
|
||||||
|
2,
|
||||||
|
3,
|
||||||
|
5,
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
* **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.
|
||||||
|
@ -156,7 +156,7 @@ 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
|
||||||
|
|
||||||
@ -175,7 +175,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 =~ a:container.prefix
|
||||||
let l:text .= ','
|
let l:text .= ','
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -226,6 +226,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 +243,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