split kakrc with filetype specific files in rc/

cpp highlighting is now specified by rc/cpp.kak.
This commit is contained in:
Maxime Coste 2012-01-15 17:35:25 +00:00
parent c62b3b251d
commit c1f625054a
4 changed files with 18 additions and 39 deletions

View File

@ -97,34 +97,6 @@ HighlighterAndId colorize_regex_factory(Window& window,
ex, fg_color, bg_color)); ex, fg_color, bg_color));
} }
void colorize_cplusplus(DisplayBuffer& display_buffer)
{
static boost::regex values("\\<(true|false|NULL|nullptr)\\>|\\<-?\\d+[fdiu]?|'((\\\\.)?|[^'\\\\])'");
colorize_regex(display_buffer, values, Color::Red);
static boost::regex builtin_types("\\<(void|int|char|unsigned|float|bool|size_t)\\>");
colorize_regex(display_buffer, builtin_types, Color::Yellow);
static boost::regex control_keywords("\\<(while|for|if|else|do|switch|case|default|goto|break|continue|return|using|try|catch|throw)\\>");
colorize_regex(display_buffer, control_keywords, Color::Blue);
//static boost::regex operators("->|\\+|\\-|\\*|/|\\\\|\\&|\\|\\^|[<>=!+-]=|=|\\(|\\)|\\[|\\]|\\{|\\}|\\<(not|and|or|xor)\\>");
//colorize_regex(display_buffer, operators, Color::Green);
static boost::regex types_keywords("\\<(const|auto|namespace|static|volatile|class|struct|enum|union|public|protected|private|template|typedef|virtual)\\>");
colorize_regex(display_buffer, types_keywords, Color::Green);
static boost::regex strings("(?<!')\"(\\\\\"|[^\"])*\"");
colorize_regex(display_buffer, strings, Color::Magenta);
static boost::regex preprocessor("(\\`|(?<=\\n))\\h*#\\h*[^\\n]*");
colorize_regex(display_buffer, preprocessor, Color::Magenta);
static boost::regex comments("(//[^\\n]*\\n)|(/\\*.*?(\\*/|\\'))");
colorize_regex(display_buffer, comments, Color::Cyan);
}
void expand_tabulations(DisplayBuffer& display_buffer) void expand_tabulations(DisplayBuffer& display_buffer)
{ {
const int tabstop = 8; const int tabstop = 8;
@ -326,7 +298,6 @@ void register_highlighters()
registry.register_factory("highlight_selections", SelectionsHighlighter::create); registry.register_factory("highlight_selections", SelectionsHighlighter::create);
registry.register_factory("expand_tabs", SimpleHighlighterFactory<expand_tabulations>("expand_tabs")); registry.register_factory("expand_tabs", SimpleHighlighterFactory<expand_tabulations>("expand_tabs"));
registry.register_factory("number_lines", SimpleHighlighterFactory<show_line_numbers>("number_lines")); registry.register_factory("number_lines", SimpleHighlighterFactory<show_line_numbers>("number_lines"));
registry.register_factory("hlcpp", SimpleHighlighterFactory<colorize_cplusplus>("hlcpp"));
registry.register_factory("regex", colorize_regex_factory); registry.register_factory("regex", colorize_regex_factory);
registry.register_factory("group", HighlighterGroup::create); registry.register_factory("group", HighlighterGroup::create);
} }

View File

@ -1,13 +1,5 @@
hook WinCreate .*\.(c|cc|cpp|cxx|C|h|hh|hpp|hxx|H) \
addhl hlcpp; \
addfilter preserve_indent; \
addfilter cleanup_whitespaces
hook WinInsertEnd .* exec xs\h+(?=\n)<ret>d hook WinInsertEnd .* exec xs\h+(?=\n)<ret>d
hook WinCreate .* addhl regex \h+(?=\n) default red hook WinCreate .* addhl regex \h+(?=\n) default red
hook WinCreate (.*/)?kakrc \ runtime rc/cpp.kak
addhl group hlkakrc; \ runtime rc/kakrc.kak
addhl -group hlkakrc regex (hook|addhl|rmhl|addfilter|rmfilter|exec) green default; \
addhl -group hlkakrc regex (?<=hook)\h+\w+\h+\H+ magenta default; \
addhl -group hlkakrc regex (?<=hook)\h+\w+ cyan default

11
src/rc/cpp.kak Normal file
View File

@ -0,0 +1,11 @@
hook WinCreate .*\.(c|cc|cpp|cxx|C|h|hh|hpp|hxx|H) \
addhl group hlcpp; \
addhl -group hlcpp regex "\<(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)\>" blue default; \
addhl -group hlcpp regex "\<(const|auto|namespace|static|volatile|class|struct|enum|union|public|protected|private|template|typedef|virtual)\>" 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

5
src/rc/kakrc.kak Normal file
View File

@ -0,0 +1,5 @@
hook WinCreate (.*/)?(kakrc|.*.kak) \
addhl group hlkakrc; \
addhl -group hlkakrc regex (hook|addhl|rmhl|addfilter|rmfilter|exec) green default; \
addhl -group hlkakrc regex (?<=hook)\h+\w+\h+\H+ magenta default; \
addhl -group hlkakrc regex (?<=hook)\h+\w+ cyan default