cpp.kak: use regex filter to handle indentation

This commit is contained in:
Maxime Coste 2012-11-21 19:07:41 +01:00
parent ff4e907fa9
commit e981fb7957

View File

@ -9,7 +9,7 @@ hook global BufOpen .* %{ %sh{
fi
} }
hook global WinSetOption filetype=cpp %{
hook global WinSetOption filetype=cpp %~
addhl group cpp-highlight
addhl -group cpp-highlight regex "\<(this|true|false|NULL|nullptr|)\>|\<-?\d+[fdiu]?|'((\\.)?|[^'\\])'" 0:value
addhl -group cpp-highlight regex "\<(void|int|char|unsigned|float|bool|size_t)\>" 0:type
@ -18,14 +18,15 @@ hook global WinSetOption filetype=cpp %{
addhl -group cpp-highlight regex "(?<!')\".*?(?<!\\)(\\\\)*\"" 0:string
addhl -group cpp-highlight regex "(\`|(?<=\n))\h*#\h*[^\n]*" 0:macro
addhl -group cpp-highlight regex "(//[^\n]*\n)|(/\*.*?(\*/|\'))" 0:comment
addfilter group cpp-filters;
addfilter -group cpp-filters preserve_indent;
addfilter -group cpp-filters cleanup_whitespaces;
addfilter group cpp-filters
addfilter -group cpp-filters regex ^(\h+)[^\n]*[^([{]\h* \n \n$1
addfilter -group cpp-filters regex ^(\h*)[^\n]*[([{]\h* \n '\n$1 '
addfilter -group cpp-filters cleanup_whitespaces
hook window InsertEnd .* %{ exec xs\h+(?=\n)<ret>d }
}
~
hook global WinSetOption filetype=(?!cpp).* %{
rmhl cpp-highlight;
rmhl cpp-highlight
rmfilter cpp-filters
}