Improve C indentation support around namespace/struct closing bracket

This commit is contained in:
Maxime Coste 2016-12-09 13:50:41 +00:00
parent ca225ad4dc
commit d8f00198f3
9 changed files with 24 additions and 2 deletions

View File

@ -68,12 +68,12 @@ def -hidden _c-family-indent-on-opening-curly-brace %[
def -hidden _c-family-indent-on-closing-curly-brace %[
# align to opening curly brace when alone on a line
try %[ exec -itersel -draft <a-h><a-k>^\h+\}$<ret>hms\`|.\'<ret>1<a-&> ]
try %[ exec -itersel -draft <a-h><a-:><a-k>^\h+\}$<ret>hms\`|.\'<ret>1<a-&> ]
]
def -hidden _c-family-insert-on-closing-curly-brace %[
# add a semicolon after a closing brace if part of a class, union or struct definition
try %[ exec -itersel -draft hm<a-x>B<a-x><a-k>^\h*(class|struct|union)<ret> a\;<esc> ]
try %[ exec -itersel -draft hm<a-x>B<a-x><a-k>\`\h*(class|struct|union)<ret> a\;<esc> ]
]
def -hidden _c-family-insert-on-newline %[ eval -draft %[

View File

@ -0,0 +1 @@
a<ret>}<esc>

View File

@ -0,0 +1,3 @@
namespace A
{
struct B%(;)

View File

@ -0,0 +1,4 @@
namespace A
{
struct B;
}

View File

@ -0,0 +1,3 @@
source "%val{runtime}/colors/default.kak"
source "%val{runtime}/rc/core/c-family.kak"
set buffer filetype cpp

View File

@ -0,0 +1 @@
a<ret>}<esc>

View File

@ -0,0 +1,3 @@
struct A
{
int i%(;)

View File

@ -0,0 +1,4 @@
struct A
{
int i;
};

View File

@ -0,0 +1,3 @@
source "%val{runtime}/colors/default.kak"
source "%val{runtime}/rc/core/c-family.kak"
set buffer filetype cpp