neovim/test/functional/plugin/vim_syntax_spec.lua
bfredl e61228a214 fix(tests): needing two calls to setup a screen is cringe
Before calling "attach" a screen object is just a dummy container for
(row, col) values whose purpose is to be sent as part of the "attach"
function call anyway.

Just create the screen in an attached state directly. Keep the complete
(row, col, options) config together. It is still completely valid to
later detach and re-attach as needed, including to another session.
2024-11-14 12:40:57 +01:00

41 lines
1.3 KiB
Lua

local n = require('test.functional.testnvim')()
local Screen = require('test.functional.ui.screen')
local clear = n.clear
local exec = n.exec
local api = n.api
describe('Vimscript syntax highlighting', function()
local screen --- @type test.functional.ui.screen
before_each(function()
clear()
n.add_builddir_to_rtp()
exec([[
setfiletype vim
syntax on
]])
screen = Screen.new()
screen:set_default_attr_ids({
[0] = { foreground = Screen.colors.Blue, bold = true },
[1] = { foreground = Screen.colors.Brown, bold = true },
[2] = { foreground = tonumber('0x6a0dad') },
})
end)
it('prefixed boolean options are highlighted properly', function()
api.nvim_buf_set_lines(0, 0, -1, true, {
'set number incsearch hlsearch',
'set nonumber noincsearch nohlsearch',
'set invnumber invincsearch invhlsearch',
})
screen:expect([[
{1:^set} {2:number} {2:incsearch} {2:hlsearch} |
{1:set} {2:nonumber} {2:noincsearch} {2:nohlsearch} |
{1:set} {2:invnumber} {2:invincsearch} {2:invhlsearch} |
{0:~ }|*10
|
]])
end)
end)