feat(highlight): add FloatFooter highlight group

Problem: No clear separation of floating title and footer highlighting.

Solution: Add new `FloatFooter` highlight group.
This commit is contained in:
Evgeni Chasnovski 2023-08-25 10:53:39 +03:00
parent 35570e4a11
commit 986bf7e78d
No known key found for this signature in database
GPG Key ID: BB32E27DDF942DFB
7 changed files with 13 additions and 6 deletions

View File

@ -479,6 +479,7 @@ to disable various visual features such as the 'number' column.
Other highlight groups specific to floating windows: Other highlight groups specific to floating windows:
- |hl-FloatBorder| for window's border - |hl-FloatBorder| for window's border
- |hl-FloatTitle| for window's title - |hl-FloatTitle| for window's title
- |hl-FloatFooter| for window's footer
Currently, floating windows don't support some widgets like scrollbar. Currently, floating windows don't support some widgets like scrollbar.
@ -3146,7 +3147,7 @@ nvim_open_win({buffer}, {enter}, {*config}) *nvim_open_win()*
Default is `"left"`. Default is `"left"`.
• footer: Footer (optional) in window border, string or • footer: Footer (optional) in window border, string or
list. List should consist of `[text, highlight]` tuples. list. List should consist of `[text, highlight]` tuples.
If string, the default highlight group is `FloatTitle`. If string, the default highlight group is `FloatFooter`.
• footer_pos: Footer position. Must be set with `footer` • footer_pos: Footer position. Must be set with `footer`
option. Value can be one of "left", "center", or "right". option. Value can be one of "left", "center", or "right".
Default is `"left"`. Default is `"left"`.

View File

@ -156,7 +156,7 @@ The following new APIs and features were added.
support fully MessagePack-RPC compliant clients. support fully MessagePack-RPC compliant clients.
• Floating windows can now show footer with new `footer` and `footer_pos` • Floating windows can now show footer with new `footer` and `footer_pos`
config fields. config fields. Uses |hl-FloatFooter| by default.
============================================================================== ==============================================================================
CHANGED FEATURES *news-changed* CHANGED FEATURES *news-changed*

View File

@ -5273,6 +5273,8 @@ NormalFloat Normal text in floating windows.
FloatBorder Border of floating windows. FloatBorder Border of floating windows.
*hl-FloatTitle* *hl-FloatTitle*
FloatTitle Title of floating windows. FloatTitle Title of floating windows.
*hl-FloatFooter*
FloatFooter Footer of floating windows.
*hl-NormalNC* *hl-NormalNC*
NormalNC Normal text in non-current windows. NormalNC Normal text in non-current windows.
*hl-Pmenu* *hl-Pmenu*

View File

@ -258,6 +258,7 @@ Highlight groups:
|hl-NormalFloat| highlights floating window |hl-NormalFloat| highlights floating window
|hl-FloatBorder| highlights border of a floating window |hl-FloatBorder| highlights border of a floating window
|hl-FloatTitle| highlights title of a floating window |hl-FloatTitle| highlights title of a floating window
|hl-FloatFooter| highlights footer of a floating window
|hl-NormalNC| highlights non-current windows |hl-NormalNC| highlights non-current windows
|hl-MsgArea| highlights messages/cmdline area |hl-MsgArea| highlights messages/cmdline area
|hl-MsgSeparator| highlights separator for scrolled messages |hl-MsgSeparator| highlights separator for scrolled messages

View File

@ -1559,7 +1559,7 @@ function vim.api.nvim_open_term(buffer, opts) end
--- Default is `"left"`. --- Default is `"left"`.
--- • footer: Footer (optional) in window border, string or --- • footer: Footer (optional) in window border, string or
--- list. List should consist of `[text, highlight]` tuples. --- list. List should consist of `[text, highlight]` tuples.
--- If string, the default highlight group is `FloatTitle`. --- If string, the default highlight group is `FloatFooter`.
--- • footer_pos: Footer position. Must be set with `footer` --- • footer_pos: Footer position. Must be set with `footer`
--- option. Value can be one of "left", "center", or "right". --- option. Value can be one of "left", "center", or "right".
--- Default is `"left"`. --- Default is `"left"`.

View File

@ -153,7 +153,7 @@
/// Default is `"left"`. /// Default is `"left"`.
/// - footer: Footer (optional) in window border, string or list. /// - footer: Footer (optional) in window border, string or list.
/// List should consist of `[text, highlight]` tuples. /// List should consist of `[text, highlight]` tuples.
/// If string, the default highlight group is `FloatTitle`. /// If string, the default highlight group is `FloatFooter`.
/// - footer_pos: Footer position. Must be set with `footer` option. /// - footer_pos: Footer position. Must be set with `footer` option.
/// Value can be one of "left", "center", or "right". /// Value can be one of "left", "center", or "right".
/// Default is `"left"`. /// Default is `"left"`.
@ -428,16 +428,19 @@ static void parse_bordertext(Object bordertext, BorderTextType bordertext_type,
bool *is_present; bool *is_present;
VirtText *chunks; VirtText *chunks;
int *width; int *width;
int default_hl_id;
switch (bordertext_type) { switch (bordertext_type) {
case kBorderTextTitle: case kBorderTextTitle:
is_present = &fconfig->title; is_present = &fconfig->title;
chunks = &fconfig->title_chunks; chunks = &fconfig->title_chunks;
width = &fconfig->title_width; width = &fconfig->title_width;
default_hl_id = syn_check_group(S_LEN("FloatTitle"));
break; break;
case kBorderTextFooter: case kBorderTextFooter:
is_present = &fconfig->footer; is_present = &fconfig->footer;
chunks = &fconfig->footer_chunks; chunks = &fconfig->footer_chunks;
width = &fconfig->footer_width; width = &fconfig->footer_width;
default_hl_id = syn_check_group(S_LEN("FloatFooter"));
break; break;
} }
@ -446,9 +449,8 @@ static void parse_bordertext(Object bordertext, BorderTextType bordertext_type,
*is_present = false; *is_present = false;
return; return;
} }
int hl_id = syn_check_group(S_LEN("FloatTitle"));
kv_push(*chunks, ((VirtTextChunk){ .text = xstrdup(bordertext.data.string.data), kv_push(*chunks, ((VirtTextChunk){ .text = xstrdup(bordertext.data.string.data),
.hl_id = hl_id })); .hl_id = default_hl_id }));
*width = (int)mb_string2cells(bordertext.data.string.data); *width = (int)mb_string2cells(bordertext.data.string.data);
*is_present = true; *is_present = true;
return; return;

View File

@ -173,6 +173,7 @@ static const char *highlight_init_both[] = {
"default link NormalFloat Pmenu", "default link NormalFloat Pmenu",
"default link FloatBorder WinSeparator", "default link FloatBorder WinSeparator",
"default link FloatTitle Title", "default link FloatTitle Title",
"default link FloatFooter Title",
"default FloatShadow blend=80 guibg=Black", "default FloatShadow blend=80 guibg=Black",
"default FloatShadowThrough blend=100 guibg=Black", "default FloatShadowThrough blend=100 guibg=Black",
"RedrawDebugNormal cterm=reverse gui=reverse", "RedrawDebugNormal cterm=reverse gui=reverse",