diff options
Diffstat (limited to 'src/rc/cpp.kak')
| -rw-r--r-- | src/rc/cpp.kak | 11 |
1 files 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 "(?<!')\".*?(?<!\\)(\\\\)*\"" 0:string addhl -group cpp-highlight regex "(//[^\n]*\n)|(/\*.*?(\*/|\'))" 0:comment hook window InsertEnd .* -id cpp-hooks %{ try %{ exec -draft <a-x>s\h+$<ret>d } } # cleanup trailing whitespaces when exiting insert mode - hook window InsertChar \n -id cpp-hooks %[ try %{ exec -draft k<a-x>s^\h+<ret>yj<a-h>P } ] # preserve previous line indent - hook window InsertChar \n -id cpp-hooks %[ try %[ exec -draft k<a-x><a-k>[{(]\h*$<ret>j<a-gt> ] ] # indent after lines ending with { or ( - hook window InsertChar \} -id cpp-hooks %[ try %[ exec -draft <a-h><a-k>^\h+\}$<ret>< ] ] # deindent on insert } alone on a line hook window InsertChar \n -id cpp-hooks %[ try %{ exec -draft k<a-x>s\h+$<ret>d } ] # cleanup trailing white space son previous line + + hook window InsertChar \n -id cpp-indent %@ + try %{ exec -draft k<a-x>s^\h+<ret>yj<a-h>P } # preserve previous line indent + try %[ exec -draft k<a-x><a-k>[{(]\h*$<ret>j<a-gt> ] # indent after lines ending with { or ( + try %{ exec -draft [(<a-k>\`\([^\n]+\n[^\n]*\n?\'<ret>s\`..|.\'<ret>& } # align to opening paren of previous line + @ + hook window InsertChar \} -id cpp-indent %[ try %[ exec -draft <a-h><a-k>^\h+\}$<ret>< ] ] # deindent on insert } alone on a line ~ hook global WinSetOption filetype=(?!cpp).* %{ rmhl cpp-highlight + rmhooks window cpp-indent rmhooks window cpp-hooks } |
