From 088f670fe94cd234643d41bfe1be71e0bf55da14 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 4 Nov 2013 22:23:55 +0000 Subject: [PATCH] update cpp indent hooks, add align to opening paren support --- src/rc/cpp.kak | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/rc/cpp.kak b/src/rc/cpp.kak index ad841cf6..d02da331 100644 --- a/src/rc/cpp.kak +++ b/src/rc/cpp.kak @@ -19,14 +19,19 @@ hook global WinSetOption filetype=cpp %~ addhl -group cpp-highlight regex "(?s\h+$d } } # cleanup trailing whitespaces when exiting insert mode - hook window InsertChar \n -id cpp-hooks %[ try %{ exec -draft ks^\h+yjP } ] # preserve previous line indent - hook window InsertChar \n -id cpp-hooks %[ try %[ exec -draft k[{(]\h*$j ] ] # indent after lines ending with { or ( - hook window InsertChar \} -id cpp-hooks %[ try %[ exec -draft ^\h+\}$< ] ] # deindent on insert } alone on a line hook window InsertChar \n -id cpp-hooks %[ try %{ exec -draft ks\h+$d } ] # cleanup trailing white space son previous line + + hook window InsertChar \n -id cpp-indent %@ + try %{ exec -draft ks^\h+yjP } # preserve previous line indent + try %[ exec -draft k[{(]\h*$j ] # indent after lines ending with { or ( + try %{ exec -draft [(\`\([^\n]+\n[^\n]*\n?\'s\`..|.\'& } # align to opening paren of previous line + @ + hook window InsertChar \} -id cpp-indent %[ try %[ exec -draft ^\h+\}$< ] ] # deindent on insert } alone on a line ~ hook global WinSetOption filetype=(?!cpp).* %{ rmhl cpp-highlight + rmhooks window cpp-indent rmhooks window cpp-hooks }