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 }