From 0b23a4f67b4e9e7db114635f8678c95e3b385c2f Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Thu, 7 Nov 2013 18:45:08 +0000 Subject: [PATCH] cpp indent improvement * auto inserts a ; after } if it closes a class or struct * auto copy the // comment of the previous line --- src/rc/cpp.kak | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/rc/cpp.kak b/src/rc/cpp.kak index c5b0f422..6e957f01 100644 --- a/src/rc/cpp.kak +++ b/src/rc/cpp.kak @@ -25,8 +25,12 @@ hook global WinSetOption filetype=cpp %~ try %[ exec -draft k[{(]\h*$j ] # indent after lines ending with { or ( try %{ exec -draft ks\h+$d } # cleanup trailing white space son previous line try %{ exec -draft [(\`\([^\n]+\n[^\n]*\n?\'s\`..|.\'& } # align to opening paren of previous line + try %{ exec -draft ks^\h*\K(/{2,})yP } # copy // comments prefix _ @ - hook window InsertChar \} -id cpp-indent %[ try %[ exec -draft ^\h+\}$< ] ] # deindent on insert } alone on a line + hook window InsertChar \} -id cpp-indent %[ + try %[ exec -draft ^\h+\}$< ] # deindent on insert } alone on a line + try %[ exec -draft "hm(class|struct)\`(class|struct)[^{}\n]+(\n)?\s*\{\'ma;" ] # add ; after } if class or struct definition + ] ~ hook global WinSetOption filetype=(?!cpp).* %{