feat(ui): allow conceal to be defined in decorations

Unlike syntax conceal, change highlight of concealed char

Can be used in tree-sitter using "conceal" metadata.
This commit is contained in:
bfredl
2022-03-19 13:48:03 +01:00
parent 463738938d
commit 6eca9b69c4
7 changed files with 100 additions and 5 deletions

View File

@@ -312,6 +312,10 @@ next_mark:
int attr = 0;
size_t j = 0;
bool conceal = 0;
int conceal_char = 0;
int conceal_attr = 0;
for (size_t i = 0; i < kv_size(state->active); i++) {
DecorRange item = kv_A(state->active, i);
bool active = false, keep = true;
@@ -336,6 +340,14 @@ next_mark:
if (active && item.attr_id > 0) {
attr = hl_combine_attr(attr, item.attr_id);
}
if (active && item.decor.conceal) {
conceal = true;
if (item.start_row == state->row && item.start_col == col && item.decor.conceal_char) {
conceal_char = item.decor.conceal_char;
state->col_until = MIN(state->col_until, item.start_col);
conceal_attr = item.attr_id;
}
}
if ((item.start_row == state->row && item.start_col <= col)
&& kv_size(item.decor.virt_text)
&& item.decor.virt_text_pos == kVTOverlay && item.win_col == -1) {
@@ -349,6 +361,9 @@ next_mark:
}
kv_size(state->active) = j;
state->current = attr;
state->conceal = conceal;
state->conceal_char = conceal_char;
state->conceal_attr = conceal_attr;
return attr;
}