diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2013-11-04 22:23:55 +0000 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2013-11-04 22:23:55 +0000 |
| commit | 088f670fe94cd234643d41bfe1be71e0bf55da14 (patch) | |
| tree | 7be7472bc5d730676e457db0a2dc4a5189f7ae3c /src/rc/cpp.kak | |
| parent | 68a27af56ec4d4afb290b32be945297c36050ab7 (diff) | |
update cpp indent hooks, add align to opening paren support
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 } |
