Merge remote-tracking branch 'GrantMoyer/preserve-tabs-for-autoindent'

This commit is contained in:
Maxime Coste 2019-03-29 20:08:59 +11:00
commit bcc8b88710
5 changed files with 18 additions and 4 deletions

View File

@ -66,10 +66,10 @@ define-command -hidden c-family-indent-on-newline %< evaluate-commands -draft -i
try %< execute-keys [c [({],[)}] <ret> >
# Validate selection and get first and last char
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 >
# Now align that new line with the opening parenthesis/brace
execute-keys &
# Now indent and align that new line with the opening parenthesis/brace
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 %[
# 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 %[

View File

@ -0,0 +1 @@
c<ret>bar<esc>

View File

@ -0,0 +1 @@
if (foo &&%( )

View File

@ -0,0 +1,2 @@
if (foo &&
bar

View 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