diff --git a/rc/make.kak b/rc/make.kak index 367e5cf3..79bc892e 100644 --- a/rc/make.kak +++ b/rc/make.kak @@ -17,6 +17,7 @@ def -shell-params make %{ %sh{ addhl -group / group make addhl -group /make regex "^([^:\n]+):(\d+):(\d+):\h+(?:((?:fatal )?error)|(warning)|(note)|(required from(?: here)?))?.*?$" 1:cyan 2:green 3:green 4:red 5:yellow 6:blue 7:yellow +addhl -group /make line_option _make_current_error_line default,blue hook global WinSetOption filetype=make %{ addhl ref make diff --git a/src/highlighters.cc b/src/highlighters.cc index b1213b6c..c7fcb748 100644 --- a/src/highlighters.cc +++ b/src/highlighters.cc @@ -391,6 +391,28 @@ HighlighterAndId highlight_regex_option_factory(HighlighterParameters params) return {"hloption_" + option_name, make_dynamic_regex_highlighter(get_regex, get_color)}; } +HighlighterAndId highlight_line_option_factory(HighlighterParameters params) +{ + if (params.size() != 2) + throw runtime_error("wrong parameter count"); + + const ColorPair& color = get_color(params[1]); + + String option_name = params[0]; + // verify option type now + GlobalOptions::instance()[option_name].get(); + + auto highlighter = [=](const Context& context, HighlightFlags flags, + DisplayBuffer& display_buffer) + { + int line = context.options()[option_name].get(); + highlight_range(display_buffer, {line-1, 0}, {line, 0}, false, + apply_colors(color)); + }; + + return {"hlline_" + option_name, std::move(highlighter)}; +} + void expand_tabulations(const Context& context, HighlightFlags flags, DisplayBuffer& display_buffer) { const int tabstop = context.options()["tabstop"].get(); @@ -1177,6 +1199,7 @@ void register_highlighters() registry.register_func("search", highlight_search_factory); registry.register_func("group", highlighter_group_factory); registry.register_func("flag_lines", flag_lines_factory); + registry.register_func("line_option", highlight_line_option_factory); registry.register_func("ref", reference_factory); registry.register_func("region", RegionHighlight::region_factory); registry.register_func("multi_region", RegionHighlight::multi_region_factory);