mirror of
https://github.com/mawww/kakoune.git
synced 2024-11-28 09:07:19 +03:00
Add a line_option highlighter that highlight the line stored in an int option
Use it to highlight the current error in the *make* buffer
This commit is contained in:
parent
6f2569ff30
commit
e202b7af50
@ -17,6 +17,7 @@ def -shell-params make %{ %sh{
|
|||||||
|
|
||||||
addhl -group / group make
|
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 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 %{
|
hook global WinSetOption filetype=make %{
|
||||||
addhl ref make
|
addhl ref make
|
||||||
|
@ -391,6 +391,28 @@ HighlighterAndId highlight_regex_option_factory(HighlighterParameters params)
|
|||||||
return {"hloption_" + option_name, make_dynamic_regex_highlighter(get_regex, get_color)};
|
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<int>();
|
||||||
|
|
||||||
|
auto highlighter = [=](const Context& context, HighlightFlags flags,
|
||||||
|
DisplayBuffer& display_buffer)
|
||||||
|
{
|
||||||
|
int line = context.options()[option_name].get<int>();
|
||||||
|
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)
|
void expand_tabulations(const Context& context, HighlightFlags flags, DisplayBuffer& display_buffer)
|
||||||
{
|
{
|
||||||
const int tabstop = context.options()["tabstop"].get<int>();
|
const int tabstop = context.options()["tabstop"].get<int>();
|
||||||
@ -1177,6 +1199,7 @@ void register_highlighters()
|
|||||||
registry.register_func("search", highlight_search_factory);
|
registry.register_func("search", highlight_search_factory);
|
||||||
registry.register_func("group", highlighter_group_factory);
|
registry.register_func("group", highlighter_group_factory);
|
||||||
registry.register_func("flag_lines", flag_lines_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("ref", reference_factory);
|
||||||
registry.register_func("region", RegionHighlight::region_factory);
|
registry.register_func("region", RegionHighlight::region_factory);
|
||||||
registry.register_func("multi_region", RegionHighlight::multi_region_factory);
|
registry.register_func("multi_region", RegionHighlight::multi_region_factory);
|
||||||
|
Loading…
Reference in New Issue
Block a user