2024-04-20 08:44:13 -07:00
|
|
|
local t = require('test.testutil')
|
|
|
|
local n = require('test.functional.testnvim')()
|
2017-11-24 10:03:06 -07:00
|
|
|
local Screen = require('test.functional.ui.screen')
|
2024-04-20 08:44:13 -07:00
|
|
|
|
|
|
|
local eq, command = t.eq, n.command
|
|
|
|
local clear = n.clear
|
|
|
|
local eval, exc_exec = n.eval, n.exc_exec
|
|
|
|
local exec = n.exec
|
|
|
|
local fn = n.fn
|
|
|
|
local api = n.api
|
2017-11-24 10:03:06 -07:00
|
|
|
|
|
|
|
describe(':highlight', function()
|
|
|
|
before_each(function()
|
|
|
|
clear()
|
2024-11-11 14:15:19 -07:00
|
|
|
local _ = Screen.new()
|
2017-11-24 10:03:06 -07:00
|
|
|
end)
|
|
|
|
|
|
|
|
it('invalid color name', function()
|
|
|
|
eq(
|
|
|
|
'Vim(highlight):E421: Color name or number not recognized: ctermfg=#181818',
|
|
|
|
exc_exec('highlight normal ctermfg=#181818')
|
2024-01-02 18:09:18 -07:00
|
|
|
)
|
2017-11-24 10:03:06 -07:00
|
|
|
eq(
|
|
|
|
'Vim(highlight):E421: Color name or number not recognized: ctermbg=#181818',
|
|
|
|
exc_exec('highlight normal ctermbg=#181818')
|
2024-01-02 18:09:18 -07:00
|
|
|
)
|
2017-11-24 10:03:06 -07:00
|
|
|
end)
|
|
|
|
|
|
|
|
it('invalid group name', function()
|
2023-05-04 16:14:39 -07:00
|
|
|
eq('Vim(highlight):E411: Highlight group not found: foo', exc_exec('highlight foo'))
|
2017-11-24 10:03:06 -07:00
|
|
|
end)
|
|
|
|
|
|
|
|
it('"Normal" foreground with red', function()
|
|
|
|
eq('', eval('synIDattr(hlID("Normal"), "fg", "cterm")'))
|
|
|
|
command('highlight normal ctermfg=red')
|
|
|
|
eq('9', eval('synIDattr(hlID("Normal"), "fg", "cterm")'))
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('"Normal" background with red', function()
|
|
|
|
eq('', eval('synIDattr(hlID("Normal"), "bg", "cterm")'))
|
|
|
|
command('highlight normal ctermbg=red')
|
|
|
|
eq('9', eval('synIDattr(hlID("Normal"), "bg", "cterm")'))
|
|
|
|
end)
|
2023-02-23 01:15:04 -07:00
|
|
|
|
|
|
|
it('only the last underline style takes effect #22371', function()
|
|
|
|
command('highlight NonText gui=underline,undercurl')
|
|
|
|
eq('', eval('synIDattr(hlID("NonText"), "underline", "gui")'))
|
|
|
|
eq('1', eval('synIDattr(hlID("NonText"), "undercurl", "gui")'))
|
|
|
|
command('highlight NonText gui=undercurl,underline')
|
|
|
|
eq('', eval('synIDattr(hlID("NonText"), "undercurl", "gui")'))
|
|
|
|
eq('1', eval('synIDattr(hlID("NonText"), "underline", "gui")'))
|
|
|
|
end)
|
2023-04-08 01:57:47 -07:00
|
|
|
|
|
|
|
it('clear', function()
|
2024-01-12 10:59:57 -07:00
|
|
|
api.nvim_set_var('colors_name', 'foo')
|
|
|
|
eq(1, fn.exists('g:colors_name'))
|
2023-04-08 01:57:47 -07:00
|
|
|
command('hi clear')
|
2024-01-12 10:59:57 -07:00
|
|
|
eq(0, fn.exists('g:colors_name'))
|
|
|
|
api.nvim_set_var('colors_name', 'foo')
|
|
|
|
eq(1, fn.exists('g:colors_name'))
|
2023-04-08 01:57:47 -07:00
|
|
|
exec([[
|
|
|
|
func HiClear()
|
|
|
|
hi clear
|
|
|
|
endfunc
|
|
|
|
]])
|
2024-01-12 10:59:57 -07:00
|
|
|
fn.HiClear()
|
|
|
|
eq(0, fn.exists('g:colors_name'))
|
2023-04-08 01:57:47 -07:00
|
|
|
end)
|
2017-11-24 10:03:06 -07:00
|
|
|
end)
|