mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 02:34:59 -07:00
feat(ui): statusline text inherits highlights #29976
Changes apply to the winbar, statusline, and tabline text.
This commit is contained in:
parent
4b90952851
commit
e049c6e4c0
@ -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.
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -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}|
|
||||
|
|
||||
]],
|
||||
}
|
||||
|
@ -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 }|
|
||||
|
|
||||
]],
|
||||
}
|
||||
|
@ -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 }|
|
||||
|
|
||||
]],
|
||||
}
|
||||
|
@ -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')
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user