cpp indent improvement

* auto inserts a ; after } if it closes a class or struct
* auto copy the // comment of the previous line
This commit is contained in:
Maxime Coste 2013-11-07 18:45:08 +00:00
parent 2eb1a323d9
commit 0b23a4f67b

View File

@ -25,8 +25,12 @@ hook global WinSetOption filetype=cpp %~
try %[ exec -draft k<a-x><a-k>[{(]\h*$<ret>j<a-gt> ] # indent after lines ending with { or (
try %{ exec -draft k<a-x>s\h+$<ret>d } # cleanup trailing white space son previous line
try %{ exec -draft [(<a-k>\`\([^\n]+\n[^\n]*\n?\'<ret>s\`..|.\'<ret>& } # align to opening paren of previous line
try %{ exec -draft <c-s>k<a-x>s^\h*\K(/{2,})<ret>y<c-o>P } # copy // comments prefix
_ @
hook window InsertChar \} -id cpp-indent %[ try %[ exec -draft <a-h><a-k>^\h+\}$<ret>< ] ] # deindent on insert } alone on a line
hook window InsertChar \} -id cpp-indent %[
try %[ exec -draft <a-h><a-k>^\h+\}$<ret>< ] # deindent on insert } alone on a line
try %[ exec -draft "hm<space><a-?>(class|struct)<ret><a-k>\`(class|struct)[^{}\n]+(\n)?\s*\{\'<ret><a-space>ma;<esc>" ] # add ; after } if class or struct definition
]
~
hook global WinSetOption filetype=(?!cpp).* %{