1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-11-23 23:34:12 +03:00

rework cpp.kak and kakrc.kak to use the filetype option

This commit is contained in:
Maxime Coste 2012-06-14 13:21:22 +00:00
parent dc91f344f7
commit 5936aa6710
2 changed files with 26 additions and 12 deletions

View File

@ -1,16 +1,24 @@
hook global WinCreate .*\.(c|cc|cpp|cxx|C|h|hh|hpp|hxx|H) \
addhl group hlcpp; \
addhl -group hlcpp regex "\<(this|true|false|NULL|nullptr|)\>|\<-?\d+[fdiu]?|'((\\.)?|[^'\\])'" red default; \
addhl -group hlcpp regex "\<(void|int|char|unsigned|float|bool|size_t)\>" yellow default; \
addhl -group hlcpp regex "\<(while|for|if|else|do|switch|case|default|goto|break|continue|return|using|try|catch|throw|new|delete|and|or|not)\>" blue default; \
addhl -group hlcpp regex "\<(const|auto|namespace|static|volatile|class|struct|enum|union|public|protected|private|template|typedef|virtual|friend|extern)\>" green default; \
addhl -group hlcpp regex "(?<!')\"(\\\"|[^\"])*\"" magenta default; \
addhl -group hlcpp regex "(\`|(?<=\n))\h*#\h*[^\n]*" magenta default; \
addhl -group hlcpp regex "(//[^\n]*\n)|(/\*.*?(\*/|\'))" cyan default; \
addfilter preserve_indent; \
addfilter cleanup_whitespaces; \
hook global BufCreate .*\.(c|cc|cpp|cxx|C|h|hh|hpp|hxx|H) \
setb filetype cpp
hook global WinSetOption filetype=cpp \
addhl group cpp-highlight; \
addhl -group cpp-highlight regex "\<(this|true|false|NULL|nullptr|)\>|\<-?\d+[fdiu]?|'((\\.)?|[^'\\])'" red default; \
addhl -group cpp-highlight regex "\<(void|int|char|unsigned|float|bool|size_t)\>" yellow default; \
addhl -group cpp-highlight regex "\<(while|for|if|else|do|switch|case|default|goto|break|continue|return|using|try|catch|throw|new|delete|and|or|not)\>" blue default; \
addhl -group cpp-highlight regex "\<(const|auto|namespace|static|volatile|class|struct|enum|union|public|protected|private|template|typedef|virtual|friend|extern|typename)\>" green default; \
addhl -group cpp-highlight regex "(?<!')\"(\\\"|[^\"])*\"" magenta default; \
addhl -group cpp-highlight regex "(\`|(?<=\n))\h*#\h*[^\n]*" magenta default; \
addhl -group cpp-highlight regex "(//[^\n]*\n)|(/\*.*?(\*/|\'))" cyan default; \
addfilter group cpp-filters; \
addfilter -group cpp-filters preserve_indent; \
addfilter -group cpp-filters cleanup_whitespaces; \
hook window InsertEnd .* exec xs\h+(?=\n)<ret>d
hook global WinSetOption filetype=(?!cpp).* \
rmhl cpp-highlight; \
rmfilter cpp-filters
hook global BufNew .*\.(h|hh|hpp|hxx|H) \
exec ggi<c-r>%<ret><esc>ggxs\.<ret>c_<esc><space>A_INCLUDED<esc>xyppI#ifndef<space><esc>jI#define<space><esc>jI#endif<space>//<space><esc>O<esc>

View File

@ -1,4 +1,7 @@
hook global WinCreate (.*/)?(kakrc|.*.kak) \
hook global BufCreate (.*/)?(kakrc|.*.kak) \
setb filetype kak
hook global WinSetOption filetype=kak \
addhl group hlkakrc; \
addhl -group hlkakrc regex \<(hook|addhl|rmhl|addfilter|rmfilter|exec|source|runtime|def|echo|edit)\> green default; \
addhl -group hlkakrc regex \<(default|black|red|green|yellow|blue|magenta|cyan|white)\> yellow default; \
@ -7,3 +10,6 @@ hook global WinCreate (.*/)?(kakrc|.*.kak) \
addhl -group hlkakrc regex (?<=\<hook)(\h+\w+) red default; \
addhl -group hlkakrc regex (?<=\<hook)(\h+(global|window)) blue default; \
addhl -group hlkakrc regex (?<=\<regex)\h+\H+ magenta default
hook global WinSetOption filetype=(?!kak).* \
rmhl hlkakrc