Preserve tabs during autoindent and alignment with '(' for c-family languages
Also add test for tab preservation during c-family autoindentation, and correct alignment of '}' with opening of block in cases of wrap between '(' and ')' in c-family languages
This commit is contained in:
parent
939471001c
commit
61840c8b11
|
@ -66,10 +66,10 @@ define-command -hidden c-family-indent-on-newline %< evaluate-commands -draft -i
|
||||||
try %< execute-keys [c [({],[)}] <ret> >
|
try %< execute-keys [c [({],[)}] <ret> >
|
||||||
# Validate selection and get first and last char
|
# Validate selection and get first and last char
|
||||||
execute-keys <a-k>\A[{(](\h*\S+)+\n<ret> <a-:><a-\;>L <a-S>
|
execute-keys <a-k>\A[{(](\h*\S+)+\n<ret> <a-:><a-\;>L <a-S>
|
||||||
# Remove eventual indent from new line
|
# Remove possibly incorrect indent from new line which was copied from previous line
|
||||||
try %< execute-keys -draft <space> <a-h> s\h+<ret> d >
|
try %< execute-keys -draft <space> <a-h> s\h+<ret> d >
|
||||||
# Now align that new line with the opening parenthesis/brace
|
# Now indent and align that new line with the opening parenthesis/brace
|
||||||
execute-keys &
|
execute-keys 1<a-&> &
|
||||||
> >
|
> >
|
||||||
> >
|
> >
|
||||||
|
|
||||||
|
@ -80,7 +80,13 @@ define-command -hidden c-family-indent-on-opening-curly-brace %[
|
||||||
|
|
||||||
define-command -hidden c-family-indent-on-closing-curly-brace %[
|
define-command -hidden c-family-indent-on-closing-curly-brace %[
|
||||||
# align to opening curly brace when alone on a line
|
# align to opening curly brace when alone on a line
|
||||||
try %[ execute-keys -itersel -draft <a-h><a-:><a-k>^\h+\}$<ret>hm<a-S>1<a-&> ]
|
try %[
|
||||||
|
# in case open curly brace follows a closing paren, align indent with opening paren
|
||||||
|
execute-keys -itersel -draft <a-h><a-:><a-k>^\h+\}$<ret>hm <a-F>)M <a-k> \A\(.*\)\h\{.*\}\z <ret> <a-S>1<a-&>
|
||||||
|
] catch %[
|
||||||
|
# otherwise align with open curly brace
|
||||||
|
execute-keys -itersel -draft <a-h><a-:><a-k>^\h+\}$<ret>hm<a-S>1<a-&>
|
||||||
|
]
|
||||||
]
|
]
|
||||||
|
|
||||||
define-command -hidden c-family-insert-on-closing-curly-brace %[
|
define-command -hidden c-family-insert-on-closing-curly-brace %[
|
||||||
|
|
1
test/indent/c-family/preserve-tabs/cmd
Normal file
1
test/indent/c-family/preserve-tabs/cmd
Normal file
|
@ -0,0 +1 @@
|
||||||
|
c<ret>bar<esc>
|
1
test/indent/c-family/preserve-tabs/in
Normal file
1
test/indent/c-family/preserve-tabs/in
Normal file
|
@ -0,0 +1 @@
|
||||||
|
if (foo &&%( )
|
2
test/indent/c-family/preserve-tabs/out
Normal file
2
test/indent/c-family/preserve-tabs/out
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
if (foo &&
|
||||||
|
bar
|
4
test/indent/c-family/preserve-tabs/rc
Normal file
4
test/indent/c-family/preserve-tabs/rc
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
source "%val{runtime}/colors/default.kak"
|
||||||
|
source "%val{runtime}/rc/filetype/c-family.kak"
|
||||||
|
set buffer indentwidth 0
|
||||||
|
set buffer filetype cpp
|
Loading…
Reference in New Issue
Block a user