update cpp indent hooks, add align to opening paren support
This commit is contained in:
parent
68a27af56e
commit
088f670fe9
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user