2024-04-20 08:44:13 -07:00
|
|
|
local t = require('test.testutil')
|
|
|
|
local n = require('test.functional.testnvim')()
|
2015-03-20 05:58:42 -07:00
|
|
|
local Screen = require('test.functional.ui.screen')
|
2017-04-08 17:07:02 -07:00
|
|
|
|
2024-04-20 08:44:13 -07:00
|
|
|
local clear, feed, insert = n.clear, n.feed, n.insert
|
|
|
|
local command, neq = n.command, t.neq
|
|
|
|
local api = n.api
|
2024-04-08 02:03:20 -07:00
|
|
|
local eq = t.eq
|
|
|
|
local pcall_err = t.pcall_err
|
2024-01-12 10:59:57 -07:00
|
|
|
local set_virtual_text = api.nvim_buf_set_virtual_text
|
2015-03-20 05:58:42 -07:00
|
|
|
|
|
|
|
describe('Buffer highlighting', function()
|
|
|
|
local screen
|
|
|
|
|
|
|
|
before_each(function()
|
|
|
|
clear()
|
2017-04-08 17:23:16 -07:00
|
|
|
command('syntax on')
|
2015-03-20 05:58:42 -07:00
|
|
|
screen = Screen.new(40, 8)
|
|
|
|
screen:set_default_attr_ids({
|
2016-08-09 05:00:41 -07:00
|
|
|
[1] = { bold = true, foreground = Screen.colors.Blue },
|
|
|
|
[2] = { foreground = Screen.colors.Fuchsia }, -- String
|
|
|
|
[3] = { foreground = Screen.colors.Brown, bold = true }, -- Statement
|
|
|
|
[4] = { foreground = Screen.colors.SlateBlue }, -- Special
|
|
|
|
[5] = { bold = true, foreground = Screen.colors.SlateBlue },
|
|
|
|
[6] = { foreground = Screen.colors.DarkCyan }, -- Identifier
|
|
|
|
[7] = { bold = true },
|
|
|
|
[8] = { underline = true, bold = true, foreground = Screen.colors.SlateBlue },
|
2017-10-19 02:46:07 -07:00
|
|
|
[9] = { foreground = Screen.colors.SlateBlue, underline = true },
|
2018-03-24 06:26:20 -07:00
|
|
|
[10] = { foreground = Screen.colors.Red },
|
|
|
|
[11] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red },
|
|
|
|
[12] = { foreground = Screen.colors.Blue1 },
|
2024-02-14 16:49:39 -07:00
|
|
|
[13] = { foreground = Screen.colors.Black, background = Screen.colors.LightGrey },
|
2018-10-23 01:10:23 -07:00
|
|
|
[14] = { background = Screen.colors.Gray90 },
|
|
|
|
[15] = { background = Screen.colors.Gray90, bold = true, foreground = Screen.colors.Brown },
|
|
|
|
[16] = { foreground = Screen.colors.Magenta, background = Screen.colors.Gray90 },
|
2019-09-20 00:37:43 -07:00
|
|
|
[17] = { foreground = Screen.colors.Magenta, background = Screen.colors.LightRed },
|
|
|
|
[18] = { background = Screen.colors.LightRed },
|
|
|
|
[19] = { foreground = Screen.colors.Blue1, background = Screen.colors.LightRed },
|
2020-01-14 04:45:09 -07:00
|
|
|
[20] = { underline = true, bold = true, foreground = Screen.colors.Cyan4 },
|
2015-03-20 05:58:42 -07:00
|
|
|
})
|
|
|
|
end)
|
|
|
|
|
2024-01-12 10:59:57 -07:00
|
|
|
local add_highlight = api.nvim_buf_add_highlight
|
|
|
|
local clear_namespace = api.nvim_buf_clear_namespace
|
2015-03-20 05:58:42 -07:00
|
|
|
|
|
|
|
it('works', function()
|
|
|
|
insert([[
|
|
|
|
these are some lines
|
|
|
|
with colorful text]])
|
|
|
|
feed('+')
|
|
|
|
|
|
|
|
screen:expect([[
|
|
|
|
these are some lines |
|
|
|
|
with colorful tex^t |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }|*5
|
2015-03-20 05:58:42 -07:00
|
|
|
|
|
|
|
|
]])
|
|
|
|
|
2024-01-12 06:11:28 -07:00
|
|
|
add_highlight(0, -1, 'String', 0, 10, 14)
|
|
|
|
add_highlight(0, -1, 'Statement', 1, 5, -1)
|
2015-03-20 05:58:42 -07:00
|
|
|
|
|
|
|
screen:expect([[
|
2016-08-09 05:00:41 -07:00
|
|
|
these are {2:some} lines |
|
|
|
|
with {3:colorful tex^t} |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }|*5
|
2015-03-20 05:58:42 -07:00
|
|
|
|
|
|
|
|
]])
|
|
|
|
|
|
|
|
feed('ggo<esc>')
|
|
|
|
screen:expect([[
|
2016-08-09 05:00:41 -07:00
|
|
|
these are {2:some} lines |
|
2015-03-20 05:58:42 -07:00
|
|
|
^ |
|
2016-08-09 05:00:41 -07:00
|
|
|
with {3:colorful text} |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }|*4
|
2015-03-20 05:58:42 -07:00
|
|
|
|
|
|
|
|
]])
|
|
|
|
|
2024-01-12 06:11:28 -07:00
|
|
|
clear_namespace(0, -1, 0, -1)
|
2015-03-20 05:58:42 -07:00
|
|
|
screen:expect([[
|
|
|
|
these are some lines |
|
|
|
|
^ |
|
|
|
|
with colorful text |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }|*4
|
2015-03-20 05:58:42 -07:00
|
|
|
|
|
|
|
|
]])
|
|
|
|
end)
|
|
|
|
|
2018-11-29 07:08:40 -07:00
|
|
|
describe('support using multiple namespaces', function()
|
2015-03-20 05:58:42 -07:00
|
|
|
local id1, id2
|
|
|
|
before_each(function()
|
|
|
|
insert([[
|
|
|
|
a longer example
|
|
|
|
in order to demonstrate
|
|
|
|
combining highlights
|
|
|
|
from different sources]])
|
|
|
|
|
2017-04-08 14:12:26 -07:00
|
|
|
command('hi ImportantWord gui=bold cterm=bold')
|
2024-01-12 06:11:28 -07:00
|
|
|
id1 = add_highlight(0, 0, 'ImportantWord', 0, 2, 8)
|
|
|
|
add_highlight(0, id1, 'ImportantWord', 1, 12, -1)
|
|
|
|
add_highlight(0, id1, 'ImportantWord', 2, 0, 9)
|
|
|
|
add_highlight(0, id1, 'ImportantWord', 3, 5, 14)
|
2015-03-20 05:58:42 -07:00
|
|
|
|
2016-08-16 12:55:37 -07:00
|
|
|
-- add_highlight can be called like this to get a new source
|
|
|
|
-- without adding any highlight
|
2024-01-12 06:11:28 -07:00
|
|
|
id2 = add_highlight(0, 0, '', 0, 0, 0)
|
2016-08-16 12:55:37 -07:00
|
|
|
neq(id1, id2)
|
|
|
|
|
2024-01-12 06:11:28 -07:00
|
|
|
add_highlight(0, id2, 'Special', 0, 2, 8)
|
|
|
|
add_highlight(0, id2, 'Identifier', 1, 3, 8)
|
|
|
|
add_highlight(0, id2, 'Special', 1, 14, 20)
|
|
|
|
add_highlight(0, id2, 'Underlined', 2, 6, 12)
|
|
|
|
add_highlight(0, id2, 'Underlined', 3, 0, 9)
|
2015-03-20 05:58:42 -07:00
|
|
|
|
|
|
|
screen:expect([[
|
2016-08-09 05:00:41 -07:00
|
|
|
a {5:longer} example |
|
|
|
|
in {6:order} to {7:de}{5:monstr}{7:ate} |
|
|
|
|
{7:combin}{8:ing}{9: hi}ghlights |
|
|
|
|
{9:from }{8:diff}{7:erent} source^s |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }|*3
|
2017-04-08 17:07:02 -07:00
|
|
|
|
|
2015-03-20 05:58:42 -07:00
|
|
|
]])
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('and clearing the first added', function()
|
2024-01-12 06:11:28 -07:00
|
|
|
clear_namespace(0, id1, 0, -1)
|
2018-11-29 07:08:40 -07:00
|
|
|
screen:expect([[
|
|
|
|
a {4:longer} example |
|
|
|
|
in {6:order} to de{4:monstr}ate |
|
|
|
|
combin{9:ing hi}ghlights |
|
|
|
|
{9:from diff}erent source^s |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }|*3
|
2018-11-29 07:08:40 -07:00
|
|
|
|
|
|
|
|
]])
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('and clearing using deprecated name', function()
|
2024-01-12 10:59:57 -07:00
|
|
|
api.nvim_buf_clear_highlight(0, id1, 0, -1)
|
2015-03-20 05:58:42 -07:00
|
|
|
screen:expect([[
|
2016-08-09 05:00:41 -07:00
|
|
|
a {4:longer} example |
|
|
|
|
in {6:order} to de{4:monstr}ate |
|
|
|
|
combin{9:ing hi}ghlights |
|
|
|
|
{9:from diff}erent source^s |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }|*3
|
2017-04-08 17:07:02 -07:00
|
|
|
|
|
2015-03-20 05:58:42 -07:00
|
|
|
]])
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('and clearing the second added', function()
|
2024-01-12 06:11:28 -07:00
|
|
|
clear_namespace(0, id2, 0, -1)
|
2015-03-20 05:58:42 -07:00
|
|
|
screen:expect([[
|
2016-08-09 05:00:41 -07:00
|
|
|
a {7:longer} example |
|
|
|
|
in order to {7:demonstrate} |
|
|
|
|
{7:combining} highlights |
|
|
|
|
from {7:different} source^s |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }|*3
|
2017-04-08 17:07:02 -07:00
|
|
|
|
|
2015-03-20 05:58:42 -07:00
|
|
|
]])
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('and clearing line ranges', function()
|
2024-01-12 06:11:28 -07:00
|
|
|
clear_namespace(0, -1, 0, 1)
|
|
|
|
clear_namespace(0, id1, 1, 2)
|
|
|
|
clear_namespace(0, id2, 2, -1)
|
2015-03-20 05:58:42 -07:00
|
|
|
screen:expect([[
|
|
|
|
a longer example |
|
2016-08-09 05:00:41 -07:00
|
|
|
in {6:order} to de{4:monstr}ate |
|
|
|
|
{7:combining} highlights |
|
|
|
|
from {7:different} source^s |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }|*3
|
2017-04-08 17:07:02 -07:00
|
|
|
|
|
2015-03-20 05:58:42 -07:00
|
|
|
]])
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('and renumbering lines', function()
|
|
|
|
feed('3Gddggo<esc>')
|
|
|
|
screen:expect([[
|
2016-08-09 05:00:41 -07:00
|
|
|
a {5:longer} example |
|
2015-03-20 05:58:42 -07:00
|
|
|
^ |
|
2016-08-09 05:00:41 -07:00
|
|
|
in {6:order} to {7:de}{5:monstr}{7:ate} |
|
|
|
|
{9:from }{8:diff}{7:erent} sources |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }|*3
|
2015-03-20 05:58:42 -07:00
|
|
|
|
|
|
|
|
]])
|
|
|
|
|
2020-01-14 04:45:09 -07:00
|
|
|
-- TODO(bfedl): this behaves a bit weirdly due to the highlight on
|
|
|
|
-- the deleted line wrapping around. we should invalidate
|
|
|
|
-- highlights when they are completely inside deleted text
|
|
|
|
command('3move 4')
|
|
|
|
screen:expect {
|
|
|
|
grid = [[
|
2016-08-09 05:00:41 -07:00
|
|
|
a {5:longer} example |
|
2015-03-20 05:58:42 -07:00
|
|
|
|
|
2020-01-14 04:45:09 -07:00
|
|
|
{8:from different sources} |
|
|
|
|
{8:^in }{20:order}{8: to demonstrate} |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }|*3
|
2020-01-14 04:45:09 -07:00
|
|
|
|
|
|
|
|
]],
|
|
|
|
}
|
|
|
|
--screen:expect([[
|
|
|
|
-- a {5:longer} example |
|
|
|
|
-- |
|
|
|
|
-- {9:from }{8:diff}{7:erent} sources |
|
|
|
|
-- ^in {6:order} to {7:de}{5:monstr}{7:ate} |
|
2023-12-09 05:42:00 -07:00
|
|
|
-- {1:~ }|*3
|
2020-01-14 04:45:09 -07:00
|
|
|
-- |
|
|
|
|
--]])
|
|
|
|
|
|
|
|
command('undo')
|
|
|
|
screen:expect {
|
|
|
|
grid = [[
|
|
|
|
a {5:longer} example |
|
|
|
|
^ |
|
|
|
|
in {6:order} to {7:de}{5:monstr}{7:ate} |
|
2016-08-09 05:00:41 -07:00
|
|
|
{9:from }{8:diff}{7:erent} sources |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }|*3
|
2020-01-14 04:45:09 -07:00
|
|
|
1 change; before #4 {MATCH:.*}|
|
|
|
|
]],
|
|
|
|
}
|
|
|
|
|
|
|
|
command('undo')
|
|
|
|
screen:expect {
|
|
|
|
grid = [[
|
|
|
|
^a {5:longer} example |
|
|
|
|
in {6:order} to {7:de}{5:monstr}{7:ate} |
|
|
|
|
{9:from }{8:diff}{7:erent} sources |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }|*4
|
2020-01-14 04:45:09 -07:00
|
|
|
1 line less; before #3 {MATCH:.*}|
|
|
|
|
]],
|
|
|
|
}
|
|
|
|
|
|
|
|
command('undo')
|
|
|
|
screen:expect {
|
|
|
|
grid = [[
|
|
|
|
a {5:longer} example |
|
|
|
|
in {6:order} to {7:de}{5:monstr}{7:ate} |
|
|
|
|
{7:^combin}{8:ing}{9: hi}ghlights |
|
|
|
|
{9:from }{8:diff}{7:erent} sources |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }|*3
|
2020-01-14 04:45:09 -07:00
|
|
|
1 more line; before #2 {MATCH:.*}|
|
|
|
|
]],
|
|
|
|
}
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('and moving lines around', function()
|
|
|
|
command('2move 3')
|
|
|
|
screen:expect {
|
|
|
|
grid = [[
|
|
|
|
a {5:longer} example |
|
|
|
|
{7:combin}{8:ing}{9: hi}ghlights |
|
2016-08-09 05:00:41 -07:00
|
|
|
^in {6:order} to {7:de}{5:monstr}{7:ate} |
|
2020-01-14 04:45:09 -07:00
|
|
|
{9:from }{8:diff}{7:erent} sources |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }|*3
|
2017-04-08 17:07:02 -07:00
|
|
|
|
|
2020-01-14 04:45:09 -07:00
|
|
|
]],
|
|
|
|
}
|
|
|
|
|
|
|
|
command('1,2move 4')
|
|
|
|
screen:expect {
|
|
|
|
grid = [[
|
|
|
|
in {6:order} to {7:de}{5:monstr}{7:ate} |
|
|
|
|
{9:from }{8:diff}{7:erent} sources |
|
|
|
|
a {5:longer} example |
|
|
|
|
{7:^combin}{8:ing}{9: hi}ghlights |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }|*3
|
2020-01-14 04:45:09 -07:00
|
|
|
|
|
|
|
|
]],
|
|
|
|
}
|
|
|
|
|
|
|
|
command('undo')
|
|
|
|
screen:expect {
|
|
|
|
grid = [[
|
|
|
|
a {5:longer} example |
|
|
|
|
{7:combin}{8:ing}{9: hi}ghlights |
|
|
|
|
^in {6:order} to {7:de}{5:monstr}{7:ate} |
|
|
|
|
{9:from }{8:diff}{7:erent} sources |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }|*3
|
2023-02-17 18:27:10 -07:00
|
|
|
2 changes; before #3 {MATCH:.*}|
|
2020-01-14 04:45:09 -07:00
|
|
|
]],
|
|
|
|
}
|
|
|
|
|
|
|
|
command('undo')
|
|
|
|
screen:expect {
|
|
|
|
grid = [[
|
|
|
|
a {5:longer} example |
|
|
|
|
^in {6:order} to {7:de}{5:monstr}{7:ate} |
|
|
|
|
{7:combin}{8:ing}{9: hi}ghlights |
|
|
|
|
{9:from }{8:diff}{7:erent} sources |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }|*3
|
2020-01-14 04:45:09 -07:00
|
|
|
1 change; before #2 {MATCH:.*}|
|
|
|
|
]],
|
|
|
|
}
|
2015-03-20 05:58:42 -07:00
|
|
|
end)
|
2018-06-29 04:35:42 -07:00
|
|
|
|
|
|
|
it('and adjusting columns', function()
|
|
|
|
-- insert before
|
|
|
|
feed('ggiquite <esc>')
|
|
|
|
screen:expect {
|
|
|
|
grid = [[
|
|
|
|
quite^ a {5:longer} example |
|
|
|
|
in {6:order} to {7:de}{5:monstr}{7:ate} |
|
|
|
|
{7:combin}{8:ing}{9: hi}ghlights |
|
|
|
|
{9:from }{8:diff}{7:erent} sources |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }|*3
|
2018-06-29 04:35:42 -07:00
|
|
|
|
|
|
|
|
]],
|
|
|
|
}
|
|
|
|
|
|
|
|
feed('u')
|
|
|
|
screen:expect {
|
|
|
|
grid = [[
|
|
|
|
^a {5:longer} example |
|
|
|
|
in {6:order} to {7:de}{5:monstr}{7:ate} |
|
|
|
|
{7:combin}{8:ing}{9: hi}ghlights |
|
|
|
|
{9:from }{8:diff}{7:erent} sources |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }|*3
|
2019-11-23 13:26:16 -07:00
|
|
|
1 change; before #2 {MATCH:.*}|
|
2018-06-29 04:35:42 -07:00
|
|
|
]],
|
|
|
|
}
|
|
|
|
|
|
|
|
-- change/insert in the middle
|
|
|
|
feed('+fesAAAA')
|
|
|
|
screen:expect {
|
|
|
|
grid = [[
|
|
|
|
a {5:longer} example |
|
|
|
|
in {6:ordAAAA^r} to {7:de}{5:monstr}{7:ate} |
|
|
|
|
{7:combin}{8:ing}{9: hi}ghlights |
|
|
|
|
{9:from }{8:diff}{7:erent} sources |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }|*3
|
2018-06-29 04:35:42 -07:00
|
|
|
{7:-- INSERT --} |
|
|
|
|
]],
|
|
|
|
}
|
|
|
|
|
|
|
|
feed('<esc>tdD')
|
|
|
|
screen:expect {
|
|
|
|
grid = [[
|
|
|
|
a {5:longer} example |
|
|
|
|
in {6:ordAAAAr} t^o |
|
|
|
|
{7:combin}{8:ing}{9: hi}ghlights |
|
|
|
|
{9:from }{8:diff}{7:erent} sources |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }|*3
|
2018-06-29 04:35:42 -07:00
|
|
|
|
|
|
|
|
]],
|
|
|
|
}
|
|
|
|
|
|
|
|
feed('u')
|
|
|
|
screen:expect {
|
|
|
|
grid = [[
|
|
|
|
a {5:longer} example |
|
2020-01-14 04:45:09 -07:00
|
|
|
in {6:ordAAAAr} to^ {7:de}{5:monstr}{7:ate} |
|
2018-06-29 04:35:42 -07:00
|
|
|
{7:combin}{8:ing}{9: hi}ghlights |
|
|
|
|
{9:from }{8:diff}{7:erent} sources |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }|*3
|
2019-11-23 13:26:16 -07:00
|
|
|
1 change; before #4 {MATCH:.*}|
|
2018-06-29 04:35:42 -07:00
|
|
|
]],
|
|
|
|
}
|
|
|
|
|
|
|
|
feed('u')
|
|
|
|
screen:expect {
|
|
|
|
grid = [[
|
|
|
|
a {5:longer} example |
|
2020-01-14 04:45:09 -07:00
|
|
|
in {6:ord^er} to {7:de}{5:monstr}{7:ate} |
|
2018-06-29 04:35:42 -07:00
|
|
|
{7:combin}{8:ing}{9: hi}ghlights |
|
|
|
|
{9:from }{8:diff}{7:erent} sources |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }|*3
|
2019-11-23 13:26:16 -07:00
|
|
|
1 change; before #3 {MATCH:.*}|
|
2018-06-29 04:35:42 -07:00
|
|
|
]],
|
|
|
|
}
|
2020-01-14 04:45:09 -07:00
|
|
|
end)
|
2018-06-29 04:35:42 -07:00
|
|
|
|
|
|
|
it('and joining lines', function()
|
|
|
|
feed('ggJJJ')
|
|
|
|
screen:expect {
|
|
|
|
grid = [[
|
|
|
|
a {5:longer} example in {6:order} to {7:de}{5:monstr}{7:ate}|
|
2020-01-14 04:45:09 -07:00
|
|
|
{7:combin}{8:ing}{9: hi}ghlights^ {9:from }{8:diff}{7:erent} sou|
|
|
|
|
rces |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }|*4
|
2018-06-29 04:35:42 -07:00
|
|
|
|
|
|
|
|
]],
|
|
|
|
}
|
|
|
|
|
|
|
|
feed('uuu')
|
|
|
|
screen:expect {
|
|
|
|
grid = [[
|
2020-01-14 04:45:09 -07:00
|
|
|
^a {5:longer} example |
|
|
|
|
in {6:order} to {7:de}{5:monstr}{7:ate} |
|
|
|
|
{7:combin}{8:ing}{9: hi}ghlights |
|
|
|
|
{9:from }{8:diff}{7:erent} sources |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }|*3
|
2019-11-23 13:26:16 -07:00
|
|
|
1 more line; before #2 {MATCH:.*}|
|
2018-06-29 04:35:42 -07:00
|
|
|
]],
|
|
|
|
}
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('and splitting lines', function()
|
|
|
|
feed('2Gtti<cr>')
|
|
|
|
screen:expect {
|
|
|
|
grid = [[
|
|
|
|
a {5:longer} example |
|
|
|
|
in {6:order} |
|
|
|
|
^ to {7:de}{5:monstr}{7:ate} |
|
|
|
|
{7:combin}{8:ing}{9: hi}ghlights |
|
|
|
|
{9:from }{8:diff}{7:erent} sources |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }|*2
|
2018-06-29 04:35:42 -07:00
|
|
|
{7:-- INSERT --} |
|
|
|
|
]],
|
|
|
|
}
|
|
|
|
|
|
|
|
feed('<esc>tsi<cr>')
|
|
|
|
screen:expect {
|
|
|
|
grid = [[
|
|
|
|
a {5:longer} example |
|
|
|
|
in {6:order} |
|
|
|
|
to {7:de}{5:mo} |
|
2020-01-14 04:45:09 -07:00
|
|
|
{5:^nstr}{7:ate} |
|
2018-06-29 04:35:42 -07:00
|
|
|
{7:combin}{8:ing}{9: hi}ghlights |
|
|
|
|
{9:from }{8:diff}{7:erent} sources |
|
|
|
|
{1:~ }|
|
|
|
|
{7:-- INSERT --} |
|
|
|
|
]],
|
|
|
|
}
|
|
|
|
|
|
|
|
feed('<esc>u')
|
|
|
|
screen:expect {
|
|
|
|
grid = [[
|
|
|
|
a {5:longer} example |
|
|
|
|
in {6:order} |
|
2020-01-14 04:45:09 -07:00
|
|
|
to {7:de}{5:mo^nstr}{7:ate} |
|
2018-06-29 04:35:42 -07:00
|
|
|
{7:combin}{8:ing}{9: hi}ghlights |
|
|
|
|
{9:from }{8:diff}{7:erent} sources |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }|*2
|
2019-11-23 13:26:16 -07:00
|
|
|
1 line less; before #3 {MATCH:.*}|
|
2018-06-29 04:35:42 -07:00
|
|
|
]],
|
|
|
|
}
|
|
|
|
|
|
|
|
feed('<esc>u')
|
|
|
|
screen:expect {
|
|
|
|
grid = [[
|
|
|
|
a {5:longer} example |
|
2020-01-14 04:45:09 -07:00
|
|
|
in {6:order}^ to {7:de}{5:monstr}{7:ate} |
|
2018-06-29 04:35:42 -07:00
|
|
|
{7:combin}{8:ing}{9: hi}ghlights |
|
|
|
|
{9:from }{8:diff}{7:erent} sources |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }|*3
|
2019-11-23 13:26:16 -07:00
|
|
|
1 line less; before #2 {MATCH:.*}|
|
2018-06-29 04:35:42 -07:00
|
|
|
]],
|
|
|
|
}
|
|
|
|
end)
|
2015-03-20 05:58:42 -07:00
|
|
|
end)
|
|
|
|
|
2020-01-14 04:45:09 -07:00
|
|
|
pending('prioritizes latest added highlight', function()
|
2015-03-20 05:58:42 -07:00
|
|
|
insert([[
|
|
|
|
three overlapping colors]])
|
2024-01-12 06:11:28 -07:00
|
|
|
add_highlight(0, 0, 'Identifier', 0, 6, 17)
|
|
|
|
add_highlight(0, 0, 'String', 0, 14, 23)
|
|
|
|
local id = add_highlight(0, 0, 'Special', 0, 0, 9)
|
2015-03-20 05:58:42 -07:00
|
|
|
|
|
|
|
screen:expect([[
|
2016-08-09 05:00:41 -07:00
|
|
|
{4:three ove}{6:rlapp}{2:ing color}^s |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }|*6
|
2015-03-20 05:58:42 -07:00
|
|
|
|
|
|
|
|
]])
|
|
|
|
|
2024-01-12 06:11:28 -07:00
|
|
|
clear_namespace(0, id, 0, 1)
|
2015-03-20 05:58:42 -07:00
|
|
|
screen:expect([[
|
2016-08-09 05:00:41 -07:00
|
|
|
three {6:overlapp}{2:ing color}^s |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }|*6
|
2015-03-20 05:58:42 -07:00
|
|
|
|
|
|
|
|
]])
|
|
|
|
end)
|
|
|
|
|
2020-01-14 04:45:09 -07:00
|
|
|
it('prioritizes earlier highlight groups (TEMP)', function()
|
|
|
|
insert([[
|
|
|
|
three overlapping colors]])
|
2024-01-12 06:11:28 -07:00
|
|
|
add_highlight(0, 0, 'Identifier', 0, 6, 17)
|
|
|
|
add_highlight(0, 0, 'String', 0, 14, 23)
|
|
|
|
local id = add_highlight(0, 0, 'Special', 0, 0, 9)
|
2020-01-14 04:45:09 -07:00
|
|
|
|
|
|
|
screen:expect {
|
|
|
|
grid = [[
|
|
|
|
{4:three }{6:overlapp}{2:ing color}^s |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }|*6
|
2020-01-14 04:45:09 -07:00
|
|
|
|
|
|
|
|
]],
|
|
|
|
}
|
|
|
|
|
2024-01-12 06:11:28 -07:00
|
|
|
clear_namespace(0, id, 0, 1)
|
2020-01-14 04:45:09 -07:00
|
|
|
screen:expect {
|
|
|
|
grid = [[
|
|
|
|
three {6:overlapp}{2:ing color}^s |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }|*6
|
2020-01-14 04:45:09 -07:00
|
|
|
|
|
|
|
|
]],
|
|
|
|
}
|
|
|
|
end)
|
|
|
|
|
2020-11-23 04:25:36 -07:00
|
|
|
it('respects priority', function()
|
2024-01-12 10:59:57 -07:00
|
|
|
local id = api.nvim_create_namespace('')
|
2020-11-23 04:25:36 -07:00
|
|
|
insert [[foobar]]
|
|
|
|
|
2024-01-12 10:59:57 -07:00
|
|
|
api.nvim_buf_set_extmark(0, id, 0, 0, {
|
2020-11-23 04:25:36 -07:00
|
|
|
end_line = 0,
|
|
|
|
end_col = 5,
|
|
|
|
hl_group = 'Statement',
|
|
|
|
priority = 100,
|
|
|
|
})
|
2024-01-12 10:59:57 -07:00
|
|
|
api.nvim_buf_set_extmark(0, id, 0, 0, {
|
2020-11-23 04:25:36 -07:00
|
|
|
end_line = 0,
|
|
|
|
end_col = 6,
|
|
|
|
hl_group = 'String',
|
|
|
|
priority = 1,
|
|
|
|
})
|
|
|
|
|
|
|
|
screen:expect [[
|
|
|
|
{3:fooba}{2:^r} |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }|*6
|
2020-11-23 04:25:36 -07:00
|
|
|
|
|
|
|
|
]]
|
|
|
|
|
2024-01-12 06:11:28 -07:00
|
|
|
clear_namespace(0, id, 0, -1)
|
2022-05-21 14:07:34 -07:00
|
|
|
screen:expect {
|
|
|
|
grid = [[
|
|
|
|
fooba^r |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }|*6
|
2022-05-21 14:07:34 -07:00
|
|
|
|
|
|
|
|
]],
|
|
|
|
}
|
2020-11-23 04:25:36 -07:00
|
|
|
|
2024-01-12 10:59:57 -07:00
|
|
|
api.nvim_buf_set_extmark(0, id, 0, 0, {
|
2020-11-23 04:25:36 -07:00
|
|
|
end_line = 0,
|
|
|
|
end_col = 6,
|
|
|
|
hl_group = 'String',
|
|
|
|
priority = 1,
|
|
|
|
})
|
2024-01-12 10:59:57 -07:00
|
|
|
api.nvim_buf_set_extmark(0, id, 0, 0, {
|
2020-11-23 04:25:36 -07:00
|
|
|
end_line = 0,
|
|
|
|
end_col = 5,
|
|
|
|
hl_group = 'Statement',
|
|
|
|
priority = 100,
|
|
|
|
})
|
|
|
|
|
|
|
|
screen:expect [[
|
|
|
|
{3:fooba}{2:^r} |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }|*6
|
2020-11-23 04:25:36 -07:00
|
|
|
|
|
|
|
|
]]
|
|
|
|
end)
|
|
|
|
|
2015-03-20 05:58:42 -07:00
|
|
|
it('works with multibyte text', function()
|
|
|
|
insert([[
|
|
|
|
Ta båten över sjön!]])
|
2024-01-12 06:11:28 -07:00
|
|
|
add_highlight(0, -1, 'Identifier', 0, 3, 9)
|
|
|
|
add_highlight(0, -1, 'String', 0, 16, 21)
|
2015-03-20 05:58:42 -07:00
|
|
|
|
|
|
|
screen:expect([[
|
2016-08-09 05:00:41 -07:00
|
|
|
Ta {6:båten} över {2:sjön}^! |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }|*6
|
2015-03-20 05:58:42 -07:00
|
|
|
|
|
|
|
|
]])
|
|
|
|
end)
|
2017-10-19 02:46:07 -07:00
|
|
|
|
|
|
|
it('works with new syntax groups', function()
|
|
|
|
insert([[
|
|
|
|
fancy code in a new fancy language]])
|
2024-01-12 06:11:28 -07:00
|
|
|
add_highlight(0, -1, 'FancyLangItem', 0, 0, 5)
|
2017-10-19 02:46:07 -07:00
|
|
|
screen:expect([[
|
|
|
|
fancy code in a new fancy languag^e |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }|*6
|
2017-10-19 02:46:07 -07:00
|
|
|
|
|
|
|
|
]])
|
|
|
|
|
|
|
|
command('hi FancyLangItem guifg=red')
|
|
|
|
screen:expect([[
|
|
|
|
{10:fancy} code in a new fancy languag^e |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }|*6
|
2017-10-19 02:46:07 -07:00
|
|
|
|
|
|
|
|
]])
|
|
|
|
end)
|
2018-03-24 06:26:20 -07:00
|
|
|
|
2020-01-14 04:45:09 -07:00
|
|
|
describe('virtual text decorations', function()
|
2018-10-23 01:10:23 -07:00
|
|
|
local id1, id2
|
|
|
|
before_each(function()
|
|
|
|
insert([[
|
|
|
|
1 + 2
|
|
|
|
3 +
|
|
|
|
x = 4]])
|
|
|
|
feed('O<esc>20A5, <esc>gg')
|
|
|
|
screen:expect([[
|
|
|
|
^1 + 2 |
|
|
|
|
3 + |
|
|
|
|
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5|
|
|
|
|
, 5, 5, 5, 5, 5, 5, |
|
|
|
|
x = 4 |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }|*2
|
2018-10-23 01:10:23 -07:00
|
|
|
|
|
|
|
|
]])
|
2018-03-24 06:26:20 -07:00
|
|
|
|
2024-01-12 06:11:28 -07:00
|
|
|
id1 = set_virtual_text(0, 0, 0, { { '=', 'Statement' }, { ' 3', 'Number' } }, {})
|
|
|
|
set_virtual_text(0, id1, 1, { { 'ERROR:', 'ErrorMsg' }, { ' invalid syntax' } }, {})
|
|
|
|
id2 = set_virtual_text(0, 0, 2, {
|
2018-10-23 01:10:23 -07:00
|
|
|
{
|
|
|
|
'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
|
2024-01-02 18:09:18 -07:00
|
|
|
},
|
2018-10-23 01:10:23 -07:00
|
|
|
}, {})
|
|
|
|
neq(id2, id1)
|
|
|
|
end)
|
2018-03-24 06:26:20 -07:00
|
|
|
|
2018-10-23 01:10:23 -07:00
|
|
|
it('works', function()
|
|
|
|
screen:expect([[
|
|
|
|
^1 + 2 {3:=}{2: 3} |
|
|
|
|
3 + {11:ERROR:} invalid syntax |
|
|
|
|
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5|
|
|
|
|
, 5, 5, 5, 5, 5, 5, Lorem ipsum dolor s|
|
|
|
|
x = 4 |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }|*2
|
2018-10-23 01:10:23 -07:00
|
|
|
|
|
|
|
|
]])
|
2018-03-24 06:26:20 -07:00
|
|
|
|
2024-01-12 06:11:28 -07:00
|
|
|
clear_namespace(0, id1, 0, -1)
|
2018-10-23 01:10:23 -07:00
|
|
|
screen:expect([[
|
|
|
|
^1 + 2 |
|
|
|
|
3 + |
|
|
|
|
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5|
|
|
|
|
, 5, 5, 5, 5, 5, 5, Lorem ipsum dolor s|
|
|
|
|
x = 4 |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }|*2
|
2018-10-23 01:10:23 -07:00
|
|
|
|
|
|
|
|
]])
|
2018-03-24 06:26:20 -07:00
|
|
|
|
2018-10-23 01:10:23 -07:00
|
|
|
-- Handles doublewidth chars, leaving a space if truncating
|
|
|
|
-- in the middle of a char
|
|
|
|
eq(
|
|
|
|
-1,
|
|
|
|
set_virtual_text(
|
2024-01-12 06:11:28 -07:00
|
|
|
0,
|
2018-10-23 01:10:23 -07:00
|
|
|
-1,
|
|
|
|
1,
|
|
|
|
{ { '暗x事zz速野谷質結育副住新覚丸活解終事', 'Comment' } },
|
|
|
|
{}
|
|
|
|
)
|
2024-01-02 18:09:18 -07:00
|
|
|
)
|
2018-10-23 01:10:23 -07:00
|
|
|
screen:expect([[
|
|
|
|
^1 + 2 |
|
|
|
|
3 + {12:暗x事zz速野谷質結育副住新覚丸活解終 }|
|
|
|
|
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5|
|
|
|
|
, 5, 5, 5, 5, 5, 5, Lorem ipsum dolor s|
|
|
|
|
x = 4 |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }|*2
|
2018-10-23 01:10:23 -07:00
|
|
|
|
|
|
|
|
]])
|
2018-03-24 06:26:20 -07:00
|
|
|
|
2018-10-23 01:10:23 -07:00
|
|
|
feed('2Gx')
|
|
|
|
screen:expect([[
|
|
|
|
1 + 2 |
|
|
|
|
^ + {12:暗x事zz速野谷質結育副住新覚丸活解終事}|
|
|
|
|
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5|
|
|
|
|
, 5, 5, 5, 5, 5, 5, Lorem ipsum dolor s|
|
|
|
|
x = 4 |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }|*2
|
2018-10-23 01:10:23 -07:00
|
|
|
|
|
|
|
|
]])
|
2018-03-24 06:26:20 -07:00
|
|
|
|
2018-10-23 01:10:23 -07:00
|
|
|
feed('2Gdd')
|
2020-01-14 04:45:09 -07:00
|
|
|
-- TODO(bfredl): currently decorations get moved from a deleted line
|
|
|
|
-- to the next one. We might want to add "invalidation" when deleting
|
|
|
|
-- over a decoration.
|
|
|
|
screen:expect {
|
|
|
|
grid = [[
|
2018-10-23 01:10:23 -07:00
|
|
|
1 + 2 |
|
|
|
|
^5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5|
|
2020-01-14 04:45:09 -07:00
|
|
|
, 5, 5, 5, 5, 5, 5, {12:暗x事zz速野谷質結育}|
|
2018-10-23 01:10:23 -07:00
|
|
|
x = 4 |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }|*3
|
2018-10-23 01:10:23 -07:00
|
|
|
|
|
2020-01-14 04:45:09 -07:00
|
|
|
]],
|
|
|
|
}
|
|
|
|
--screen:expect([[
|
|
|
|
-- 1 + 2 |
|
|
|
|
-- ^5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5|
|
|
|
|
-- , 5, 5, 5, 5, 5, 5, Lorem ipsum dolor s|
|
|
|
|
-- x = 4 |
|
2023-12-09 05:42:00 -07:00
|
|
|
-- {1:~ }|*3
|
2020-01-14 04:45:09 -07:00
|
|
|
-- |
|
|
|
|
--]])
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('validates contents', function()
|
|
|
|
-- this used to leak memory
|
2023-02-14 12:19:28 -07:00
|
|
|
eq(
|
|
|
|
"Invalid 'chunk': expected Array, got String",
|
2024-01-12 06:11:28 -07:00
|
|
|
pcall_err(set_virtual_text, 0, id1, 0, { 'texty' }, {})
|
2024-01-02 18:09:18 -07:00
|
|
|
)
|
2023-02-14 12:19:28 -07:00
|
|
|
eq(
|
|
|
|
"Invalid 'chunk': expected Array, got String",
|
2024-01-12 06:11:28 -07:00
|
|
|
pcall_err(set_virtual_text, 0, id1, 0, { { 'very' }, 'texty' }, {})
|
2024-01-02 18:09:18 -07:00
|
|
|
)
|
2018-10-23 01:10:23 -07:00
|
|
|
end)
|
2018-03-24 06:26:20 -07:00
|
|
|
|
2019-11-10 08:38:04 -07:00
|
|
|
it('can be retrieved', function()
|
2024-01-12 10:59:57 -07:00
|
|
|
local get_extmarks = api.nvim_buf_get_extmarks
|
|
|
|
local line_count = api.nvim_buf_line_count
|
2019-11-10 08:38:04 -07:00
|
|
|
|
|
|
|
local s1 = { { 'Köttbullar', 'Comment' }, { 'Kräuterbutter' } }
|
|
|
|
local s2 = { { 'こんにちは', 'Comment' } }
|
|
|
|
|
2024-01-12 06:11:28 -07:00
|
|
|
set_virtual_text(0, id1, 0, s1, {})
|
2022-01-13 07:26:57 -07:00
|
|
|
eq({
|
|
|
|
{
|
|
|
|
1,
|
|
|
|
0,
|
|
|
|
0,
|
2024-01-02 18:09:18 -07:00
|
|
|
{
|
2023-03-24 18:24:24 -07:00
|
|
|
ns_id = 1,
|
2022-01-13 07:26:57 -07:00
|
|
|
priority = 0,
|
|
|
|
virt_text = s1,
|
|
|
|
-- other details
|
2022-01-23 17:52:13 -07:00
|
|
|
right_gravity = true,
|
2023-12-25 16:16:03 -07:00
|
|
|
virt_text_repeat_linebreak = false,
|
2022-01-13 07:26:57 -07:00
|
|
|
virt_text_pos = 'eol',
|
|
|
|
virt_text_hide = false,
|
2024-01-02 18:09:18 -07:00
|
|
|
},
|
|
|
|
},
|
2024-01-12 06:11:28 -07:00
|
|
|
}, get_extmarks(0, id1, { 0, 0 }, { 0, -1 }, { details = true }))
|
2019-11-10 08:38:04 -07:00
|
|
|
|
2024-01-12 06:11:28 -07:00
|
|
|
local lastline = line_count(0)
|
|
|
|
set_virtual_text(0, id1, line_count(0), s2, {})
|
2022-01-13 07:26:57 -07:00
|
|
|
eq({
|
|
|
|
{
|
|
|
|
3,
|
|
|
|
lastline,
|
|
|
|
0,
|
2024-01-02 18:09:18 -07:00
|
|
|
{
|
2023-03-24 18:24:24 -07:00
|
|
|
ns_id = 1,
|
2022-01-13 07:26:57 -07:00
|
|
|
priority = 0,
|
|
|
|
virt_text = s2,
|
|
|
|
-- other details
|
2022-01-23 17:52:13 -07:00
|
|
|
right_gravity = true,
|
2023-12-25 16:16:03 -07:00
|
|
|
virt_text_repeat_linebreak = false,
|
2022-01-13 07:26:57 -07:00
|
|
|
virt_text_pos = 'eol',
|
|
|
|
virt_text_hide = false,
|
2024-01-02 18:09:18 -07:00
|
|
|
},
|
|
|
|
},
|
2024-01-12 06:11:28 -07:00
|
|
|
}, get_extmarks(0, id1, { lastline, 0 }, { lastline, -1 }, { details = true }))
|
2024-01-02 18:09:18 -07:00
|
|
|
|
2024-01-12 06:11:28 -07:00
|
|
|
eq({}, get_extmarks(0, id1, { lastline + 9000, 0 }, { lastline + 9000, -1 }, {}))
|
2019-11-10 08:38:04 -07:00
|
|
|
end)
|
|
|
|
|
2018-10-23 01:10:23 -07:00
|
|
|
it('is not highlighted by visual selection', function()
|
|
|
|
feed('ggVG')
|
|
|
|
screen:expect([[
|
|
|
|
{13:1 + 2} {3:=}{2: 3} |
|
|
|
|
{13:3 +} {11:ERROR:} invalid syntax |
|
|
|
|
{13:5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5}|
|
|
|
|
{13:, 5, 5, 5, 5, 5, 5, } Lorem ipsum dolor s|
|
|
|
|
^x{13: = 4} |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }|*2
|
2018-10-23 01:10:23 -07:00
|
|
|
{7:-- VISUAL LINE --} |
|
|
|
|
]])
|
2018-03-24 06:26:20 -07:00
|
|
|
|
2018-10-23 01:10:23 -07:00
|
|
|
feed('<esc>')
|
|
|
|
screen:expect([[
|
|
|
|
1 + 2 {3:=}{2: 3} |
|
|
|
|
3 + {11:ERROR:} invalid syntax |
|
|
|
|
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5|
|
|
|
|
, 5, 5, 5, 5, 5, 5, Lorem ipsum dolor s|
|
|
|
|
^x = 4 |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }|*2
|
2018-10-23 01:10:23 -07:00
|
|
|
|
|
|
|
|
]])
|
2018-03-24 06:26:20 -07:00
|
|
|
|
2018-10-23 01:10:23 -07:00
|
|
|
-- special case: empty line has extra eol highlight
|
|
|
|
feed('ggd$')
|
|
|
|
screen:expect([[
|
|
|
|
^ {3:=}{2: 3} |
|
|
|
|
3 + {11:ERROR:} invalid syntax |
|
|
|
|
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5|
|
|
|
|
, 5, 5, 5, 5, 5, 5, Lorem ipsum dolor s|
|
|
|
|
x = 4 |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }|*2
|
2018-10-23 01:10:23 -07:00
|
|
|
|
|
|
|
|
]])
|
2018-03-24 06:26:20 -07:00
|
|
|
|
2018-10-23 01:10:23 -07:00
|
|
|
feed('jvk')
|
|
|
|
screen:expect([[
|
|
|
|
^ {3:=}{2: 3} |
|
|
|
|
{13:3} + {11:ERROR:} invalid syntax |
|
|
|
|
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5|
|
|
|
|
, 5, 5, 5, 5, 5, 5, Lorem ipsum dolor s|
|
|
|
|
x = 4 |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }|*2
|
2018-10-23 01:10:23 -07:00
|
|
|
{7:-- VISUAL --} |
|
|
|
|
]])
|
|
|
|
|
|
|
|
feed('o')
|
|
|
|
screen:expect([[
|
|
|
|
{13: }{3:=}{2: 3} |
|
|
|
|
^3 + {11:ERROR:} invalid syntax |
|
|
|
|
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5|
|
|
|
|
, 5, 5, 5, 5, 5, 5, Lorem ipsum dolor s|
|
|
|
|
x = 4 |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }|*2
|
2018-10-23 01:10:23 -07:00
|
|
|
{7:-- VISUAL --} |
|
|
|
|
]])
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('works with listchars', function()
|
|
|
|
command('set list listchars+=eol:$')
|
|
|
|
screen:expect([[
|
|
|
|
^1 + 2{1:$}{3:=}{2: 3} |
|
|
|
|
3 +{1:$}{11:ERROR:} invalid syntax |
|
|
|
|
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5|
|
|
|
|
, 5, 5, 5, 5, 5, 5,{1:-$}Lorem ipsum dolor s|
|
|
|
|
x = 4{1:$} |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }|*2
|
2018-10-23 01:10:23 -07:00
|
|
|
|
|
|
|
|
]])
|
|
|
|
|
2024-01-12 06:11:28 -07:00
|
|
|
clear_namespace(0, -1, 0, -1)
|
2018-10-23 01:10:23 -07:00
|
|
|
screen:expect([[
|
|
|
|
^1 + 2{1:$} |
|
|
|
|
3 +{1:$} |
|
|
|
|
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5|
|
|
|
|
, 5, 5, 5, 5, 5, 5,{1:-$} |
|
|
|
|
x = 4{1:$} |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }|*2
|
2018-10-23 01:10:23 -07:00
|
|
|
|
|
|
|
|
]])
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('works with cursorline', function()
|
|
|
|
command('set cursorline')
|
|
|
|
|
2021-07-25 05:33:28 -07:00
|
|
|
screen:expect {
|
|
|
|
grid = [[
|
|
|
|
{14:^1 + 2 }{3:=}{2: 3}{14: }|
|
2018-10-23 01:10:23 -07:00
|
|
|
3 + {11:ERROR:} invalid syntax |
|
|
|
|
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5|
|
|
|
|
, 5, 5, 5, 5, 5, 5, Lorem ipsum dolor s|
|
|
|
|
x = 4 |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }|*2
|
2018-10-23 01:10:23 -07:00
|
|
|
|
|
2021-07-25 05:33:28 -07:00
|
|
|
]],
|
|
|
|
}
|
2018-10-23 01:10:23 -07:00
|
|
|
|
|
|
|
feed('j')
|
2021-07-25 05:33:28 -07:00
|
|
|
screen:expect {
|
|
|
|
grid = [[
|
2018-10-23 01:10:23 -07:00
|
|
|
1 + 2 {3:=}{2: 3} |
|
2021-07-25 05:33:28 -07:00
|
|
|
{14:^3 + }{11:ERROR:} invalid syntax{14: }|
|
2018-10-23 01:10:23 -07:00
|
|
|
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5|
|
|
|
|
, 5, 5, 5, 5, 5, 5, Lorem ipsum dolor s|
|
|
|
|
x = 4 |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }|*2
|
2018-10-23 01:10:23 -07:00
|
|
|
|
|
2021-07-25 05:33:28 -07:00
|
|
|
]],
|
|
|
|
}
|
2018-10-23 01:10:23 -07:00
|
|
|
|
|
|
|
feed('j')
|
2021-07-25 05:33:28 -07:00
|
|
|
screen:expect {
|
|
|
|
grid = [[
|
2018-10-23 01:10:23 -07:00
|
|
|
1 + 2 {3:=}{2: 3} |
|
|
|
|
3 + {11:ERROR:} invalid syntax |
|
|
|
|
{14:^5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5}|
|
2021-07-25 05:33:28 -07:00
|
|
|
{14:, 5, 5, 5, 5, 5, 5, }Lorem ipsum dolor s|
|
2018-10-23 01:10:23 -07:00
|
|
|
x = 4 |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }|*2
|
2018-10-23 01:10:23 -07:00
|
|
|
|
|
2021-07-25 05:33:28 -07:00
|
|
|
]],
|
|
|
|
}
|
2018-10-23 01:10:23 -07:00
|
|
|
end)
|
2019-09-20 00:37:43 -07:00
|
|
|
|
|
|
|
it('works with color column', function()
|
2024-01-12 06:11:28 -07:00
|
|
|
eq(-1, set_virtual_text(0, -1, 3, { { '暗x事', 'Comment' } }, {}))
|
2019-09-20 00:37:43 -07:00
|
|
|
screen:expect {
|
|
|
|
grid = [[
|
|
|
|
^1 + 2 {3:=}{2: 3} |
|
|
|
|
3 + {11:ERROR:} invalid syntax |
|
|
|
|
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5|
|
|
|
|
, 5, 5, 5, 5, 5, 5, Lorem ipsum dolor s|
|
|
|
|
x = 4 {12:暗x事} |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }|*2
|
2019-09-20 00:37:43 -07:00
|
|
|
|
|
|
|
|
]],
|
|
|
|
}
|
|
|
|
|
|
|
|
command('set colorcolumn=9')
|
|
|
|
screen:expect {
|
|
|
|
grid = [[
|
2021-07-25 05:33:28 -07:00
|
|
|
^1 + 2 {3:=}{2: 3} |
|
2019-09-20 00:37:43 -07:00
|
|
|
3 + {11:ERROR:} invalid syntax |
|
|
|
|
5, 5, 5,{18: }5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5|
|
|
|
|
, 5, 5, 5, 5, 5, 5, Lorem ipsum dolor s|
|
2021-07-25 05:33:28 -07:00
|
|
|
x = 4 {12:暗x事} |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }|*2
|
2019-09-20 00:37:43 -07:00
|
|
|
|
|
|
|
|
]],
|
|
|
|
}
|
|
|
|
end)
|
2018-03-24 06:26:20 -07:00
|
|
|
end)
|
2018-10-23 01:10:23 -07:00
|
|
|
|
2018-12-07 09:28:51 -07:00
|
|
|
it('and virtual text use the same namespace counter', function()
|
2024-01-12 06:11:28 -07:00
|
|
|
eq(1, add_highlight(0, 0, 'String', 0, 0, -1))
|
|
|
|
eq(2, set_virtual_text(0, 0, 0, { { '= text', 'Comment' } }, {}))
|
2024-01-12 10:59:57 -07:00
|
|
|
eq(3, api.nvim_create_namespace('my-ns'))
|
2024-01-12 06:11:28 -07:00
|
|
|
eq(4, add_highlight(0, 0, 'String', 0, 0, -1))
|
|
|
|
eq(5, set_virtual_text(0, 0, 0, { { '= text', 'Comment' } }, {}))
|
2024-01-12 10:59:57 -07:00
|
|
|
eq(6, api.nvim_create_namespace('other-ns'))
|
2018-12-07 09:28:51 -07:00
|
|
|
end)
|
2015-03-20 05:58:42 -07:00
|
|
|
end)
|