Golang do not align to open ( or {
Changed the indentation behavior such that an extra level of indentation is added after a line containing a ( or { that is not closed on the same line instead of aligning to the unclosed ( or {. This is consistent with how `go fmt` formats source code. Added regression tests.
This commit is contained in:
parent
039a10a34c
commit
680dc8cd91
|
@ -111,10 +111,8 @@ define-command -hidden go-indent-on-new-line %~
|
||||||
execute-keys -draft <a-?> /\* <ret> <a-K>\*/<ret>
|
execute-keys -draft <a-?> /\* <ret> <a-K>\*/<ret>
|
||||||
}
|
}
|
||||||
} catch %{
|
} catch %{
|
||||||
# indent after lines ending with { or (
|
# indent after lines with an unclosed { or (
|
||||||
try %[ execute-keys -draft k<a-x> <a-k> [{(]\h*$ <ret> j<a-gt> ]
|
try %< execute-keys -draft [c[({],[)}] <ret> <a-k> \A[({][^\n]*\n[^\n]*\n?\z <ret> j<a-gt> >
|
||||||
# align to opening paren of previous line
|
|
||||||
try %{ execute-keys -draft [( <a-k> \A\([^\n]+\n[^\n]*\n?\z <ret> s \A\(\h*.|.\z <ret> '<a-;>' & }
|
|
||||||
# indent after a switch's case/default statements
|
# indent after a switch's case/default statements
|
||||||
try %[ execute-keys -draft k<a-x> <a-k> ^\h*(case|default).*:$ <ret> j<a-gt> ]
|
try %[ execute-keys -draft k<a-x> <a-k> ^\h*(case|default).*:$ <ret> j<a-gt> ]
|
||||||
# deindent closing brace(s) when after cursor
|
# deindent closing brace(s) when after cursor
|
||||||
|
|
|
@ -47,3 +47,9 @@ a := []int{
|
||||||
someFunction(%( )
|
someFunction(%( )
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
14
|
||||||
|
foobar(baz,%( )
|
||||||
|
|
||||||
|
15
|
||||||
|
foobar{ // some comment%( )
|
||||||
|
|
|
@ -63,3 +63,11 @@ a := []int{
|
||||||
|
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
14
|
||||||
|
foobar(baz,
|
||||||
|
|
||||||
|
|
||||||
|
15
|
||||||
|
foobar{ // some comment
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user