aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRiley Bruins <ribru17@hotmail.com>2024-10-12 10:57:31 -0700
committerGitHub <noreply@github.com>2024-10-12 10:57:31 -0700
commite049c6e4c08a141c94218672e770f86f91c27a11 (patch)
tree9ee26aa2f39b30a86410d79a425b1a440c807822
parent4b909528516032b002a4a32f3e06f0eb6185ea6b (diff)
downloadrneovim-e049c6e4c08a141c94218672e770f86f91c27a11.tar.gz
rneovim-e049c6e4c08a141c94218672e770f86f91c27a11.tar.bz2
rneovim-e049c6e4c08a141c94218672e770f86f91c27a11.zip
feat(ui): statusline text inherits highlights #29976
Changes apply to the winbar, statusline, and tabline text.
-rw-r--r--runtime/doc/news.txt4
-rw-r--r--src/nvim/statusline.c2
-rw-r--r--test/functional/ui/highlight_spec.lua13
-rw-r--r--test/functional/ui/multibyte_spec.lua20
-rw-r--r--test/functional/ui/statusline_spec.lua3
-rw-r--r--test/functional/ui/tabline_spec.lua20
-rw-r--r--test/functional/ui/winbar_spec.lua22
7 files changed, 74 insertions, 10 deletions
diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt
index 6af136bb5a..5c93128f25 100644
--- a/runtime/doc/news.txt
+++ b/runtime/doc/news.txt
@@ -262,6 +262,10 @@ These existing features changed their behavior.
more emoji characters than before, including those encoded with multiple
emoji codepoints combined with ZWJ (zero width joiner) codepoints.
+• Text in the 'statusline', 'tabline', and 'winbar' now inherits highlights
+ from the respective |hl-StatusLine|, |hl-TabLine|, and |hl-WinBar| highlight
+ groups.
+
• |vim.on_key()| callbacks won't be invoked recursively when a callback itself
consumes input.
diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c
index 07bb7dd69a..6b8f5e27a3 100644
--- a/src/nvim/statusline.c
+++ b/src/nvim/statusline.c
@@ -430,7 +430,7 @@ static void win_redr_custom(win_T *wp, bool draw_winbar, bool draw_ruler)
if (hltab[n].userhl == 0) {
curattr = attr;
} else if (hltab[n].userhl < 0) {
- curattr = syn_id2attr(-hltab[n].userhl);
+ curattr = hl_combine_attr(attr, syn_id2attr(-hltab[n].userhl));
} else if (wp != NULL && wp != curwin && wp->w_status_height != 0) {
curattr = highlight_stlnc[hltab[n].userhl - 1];
} else {
diff --git a/test/functional/ui/highlight_spec.lua b/test/functional/ui/highlight_spec.lua
index 87d66fa604..47b923c8e2 100644
--- a/test/functional/ui/highlight_spec.lua
+++ b/test/functional/ui/highlight_spec.lua
@@ -1691,6 +1691,7 @@ describe("'winhighlight' highlight", function()
[29] = { foreground = Screen.colors.Blue1, background = Screen.colors.Red, bold = true },
[30] = { background = tonumber('0xff8800') },
[31] = { background = tonumber('0xff8800'), bold = true, foreground = Screen.colors.Blue },
+ [32] = { bold = true, reverse = true, background = Screen.colors.DarkGreen },
}
command('hi Background1 guibg=DarkBlue')
command('hi Background2 guibg=DarkGreen')
@@ -2253,10 +2254,10 @@ describe("'winhighlight' highlight", function()
some text |
more tex^t |
{0:~ }|
- {3:[No Name] }{1:2,9 All}|
+ {3:[No Name] }{11:2,9 All}|
some text |
more text |
- {4:[No Name] }{1:1,1 All}|
+ {4:[No Name] }{14:1,1 All}|
|
]],
}
@@ -2267,10 +2268,10 @@ describe("'winhighlight' highlight", function()
some text |
more tex^t |
{0:~ }|
- {3:[No Name] }{5:2,9 All}|
+ {3:[No Name] }{32:2,9 All}|
some text |
more text |
- {4:[No Name] }{1:1,1 All}|
+ {4:[No Name] }{14:1,1 All}|
|
]],
}
@@ -2281,10 +2282,10 @@ describe("'winhighlight' highlight", function()
some tex^t |
more text |
{0:~ }|
- {3:[No Name] }{5:1,9 All}|
+ {3:[No Name] }{32:1,9 All}|
some text |
more text |
- {4:[No Name] }{1:1,1 All}|
+ {4:[No Name] }{14:1,1 All}|
|
]],
}
diff --git a/test/functional/ui/multibyte_spec.lua b/test/functional/ui/multibyte_spec.lua
index f16f750ea1..3728ec8dbc 100644
--- a/test/functional/ui/multibyte_spec.lua
+++ b/test/functional/ui/multibyte_spec.lua
@@ -474,26 +474,42 @@ describe('multibyte rendering: statusline', function()
end)
it('emoji with ZWJ in filename with custom stl', function()
+ screen:add_extra_attr_ids {
+ [100] = {
+ bold = true,
+ reverse = true,
+ foreground = Screen.colors.Gray100,
+ background = Screen.colors.Red,
+ },
+ }
command('set statusline=xx%#ErrorMsg#%f%##yy')
command('file 🧑‍💻')
screen:expect {
grid = [[
^ |
{1:~ }|
- {3:xx}{9:🧑‍💻}{3:yy }|
+ {3:xx}{100:🧑‍💻}{3:yy }|
|
]],
}
end)
it('unprintable chars in filename with custom stl', function()
+ screen:add_extra_attr_ids {
+ [100] = {
+ bold = true,
+ reverse = true,
+ foreground = Screen.colors.Gray100,
+ background = Screen.colors.Red,
+ },
+ }
command('set statusline=xx%#ErrorMsg#%f%##yy')
command('file 🧑​💻')
screen:expect {
grid = [[
^ |
{1:~ }|
- {3:xx}{9:🧑<200b>💻}{3:yy }|
+ {3:xx}{100:🧑<200b>💻}{3:yy }|
|
]],
}
diff --git a/test/functional/ui/statusline_spec.lua b/test/functional/ui/statusline_spec.lua
index 937e709d66..001d927cb1 100644
--- a/test/functional/ui/statusline_spec.lua
+++ b/test/functional/ui/statusline_spec.lua
@@ -27,6 +27,7 @@ for _, model in ipairs(mousemodels) do
screen:set_default_attr_ids({
[0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText
[1] = { bold = true, reverse = true }, -- StatusLine
+ [2] = { bold = true, foreground = Screen.colors.Blue, reverse = true }, -- NonText combined with StatusLine
})
screen:attach()
command('set laststatus=2 mousemodel=' .. model)
@@ -87,7 +88,7 @@ for _, model in ipairs(mousemodels) do
grid = [[
^ |
{0:~ }|*5
- {1:^I}{0:^A^I^A^I}{1:^A }|
+ {1:^I}{2:^A^I^A^I}{1:^A }|
|
]],
}
diff --git a/test/functional/ui/tabline_spec.lua b/test/functional/ui/tabline_spec.lua
index 5cda70df21..de1e701101 100644
--- a/test/functional/ui/tabline_spec.lua
+++ b/test/functional/ui/tabline_spec.lua
@@ -125,6 +125,26 @@ describe('tabline', function()
}
end)
+ it('combines highlight attributes', function()
+ screen:set_default_attr_ids({
+ [1] = { foreground = Screen.colors.Blue1, bold = true }, -- StatusLine
+ [2] = { bold = true, italic = true }, -- StatusLine
+ [3] = { bold = true, italic = true, foreground = Screen.colors.Red }, -- NonText combined with StatusLine
+ })
+ command('hi TabLineFill gui=bold,italic')
+ command('hi Identifier guifg=red')
+ command('set tabline=Test%#Identifier#here')
+ command('set showtabline=2')
+ screen:expect {
+ grid = [[
+ {2:Test}{3:here }|
+ ^ |
+ {1:~ }|*2
+ |
+ ]],
+ }
+ end)
+
it('click definitions do not leak memory #21765', function()
command('set tabline=%@MyClickFunc@MyClickText%T')
command('set showtabline=2')
diff --git a/test/functional/ui/winbar_spec.lua b/test/functional/ui/winbar_spec.lua
index fb907026a5..bbdf3ad9ba 100644
--- a/test/functional/ui/winbar_spec.lua
+++ b/test/functional/ui/winbar_spec.lua
@@ -40,6 +40,16 @@ describe('winbar', function()
bold = true,
foreground = Screen.colors.Magenta,
},
+ [12] = {
+ underline = true,
+ background = Screen.colors.Red,
+ },
+ [13] = {
+ underline = true,
+ bold = true,
+ foreground = Screen.colors.Blue,
+ background = Screen.colors.Red,
+ },
})
api.nvim_set_option_value('winbar', 'Set Up The Bars', {})
end)
@@ -182,6 +192,18 @@ describe('winbar', function()
]])
end)
+ it('works with combined highlight attributes', function()
+ command('hi Winbar guibg=red gui=underline')
+ command('hi Identifier guifg=blue gui=bold')
+ command('set winbar=Lookatmy%#Identifier#highlights')
+ screen:expect([[
+ {12:Lookatmy}{13:highlights }|
+ ^ |
+ {3:~ }|*10
+ |
+ ]])
+ end)
+
it('can be ruler', function()
insert [[
just some