aboutsummaryrefslogtreecommitdiff
path: root/test/functional/ui/decorations_spec.lua
diff options
context:
space:
mode:
authoraltermo <107814000+altermo@users.noreply.github.com>2024-02-06 11:52:42 +0100
committeraltermo <107814000+altermo@users.noreply.github.com>2024-02-21 16:11:50 +0100
commit1c032ad703a19cd5c8498ee95f9352df87a91139 (patch)
tree9c2c79ae6dc17feb4c63687069cb1b9805fcc1bb /test/functional/ui/decorations_spec.lua
parent6d8bbfe19df2175637a1e47ac1aafb0e96e35b38 (diff)
downloadrneovim-1c032ad703a19cd5c8498ee95f9352df87a91139.tar.gz
rneovim-1c032ad703a19cd5c8498ee95f9352df87a91139.tar.bz2
rneovim-1c032ad703a19cd5c8498ee95f9352df87a91139.zip
feat(extmark): window scoped extmark
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
Diffstat (limited to 'test/functional/ui/decorations_spec.lua')
-rw-r--r--test/functional/ui/decorations_spec.lua330
1 files changed, 330 insertions, 0 deletions
diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua
index 0ba33ec3d4..ac52b8a3c5 100644
--- a/test/functional/ui/decorations_spec.lua
+++ b/test/functional/ui/decorations_spec.lua
@@ -5468,3 +5468,333 @@ describe('decorations: virt_text', function()
]]}
end)
end)
+
+describe('decorations: window scoped', function()
+ local screen, ns
+ before_each(function()
+ clear()
+ screen = Screen.new(20, 10)
+ screen:attach()
+ screen:set_default_attr_ids {
+ [1] = { foreground = Screen.colors.Blue1 },
+ [2] = { foreground = Screen.colors.Blue1, bold = true },
+ }
+
+ ns = api.nvim_create_namespace 'test'
+
+ insert('12345')
+ end)
+
+ local noextmarks = {
+ grid = [[
+ 1234^5 |
+ {2:~ }|*8
+ |
+ ]]}
+
+ local function set_scoped_extmark(line, col, opts)
+ return api.nvim_buf_set_extmark(0, ns, line, col, vim.tbl_extend('error', { scoped = true }, opts))
+ end
+
+ it('hl_group', function()
+ set_scoped_extmark(0, 0, {
+ hl_group = 'Comment',
+ end_col = 3,
+ })
+
+ screen:expect(noextmarks)
+
+ api.nvim_win_add_ns(0, ns)
+
+ screen:expect {
+ grid = [[
+ {1:123}4^5 |
+ {2:~ }|*8
+ |
+ ]]}
+
+ command 'split'
+ command 'only'
+
+ screen:expect(noextmarks)
+ end)
+
+ it('virt_text', function()
+ set_scoped_extmark(0, 0, {
+ virt_text = { { 'a', 'Comment' } },
+ virt_text_pos = 'eol',
+ })
+ set_scoped_extmark(0, 5, {
+ virt_text = { { 'b', 'Comment' } },
+ virt_text_pos = 'inline',
+ })
+ set_scoped_extmark(0, 1, {
+ virt_text = { { 'c', 'Comment' } },
+ virt_text_pos = 'overlay',
+ })
+ set_scoped_extmark(0, 1, {
+ virt_text = { { 'd', 'Comment' } },
+ virt_text_pos = 'right_align',
+ })
+
+ screen:expect(noextmarks)
+
+ api.nvim_win_add_ns(0, ns)
+
+ screen:expect {
+ grid = [[
+ 1{1:c}34^5{1:b} {1:a} {1:d}|
+ {2:~ }|*8
+ |
+ ]]}
+
+ command 'split'
+ command 'only'
+
+ screen:expect(noextmarks)
+ end)
+
+ it('virt_lines', function()
+ set_scoped_extmark(0, 0, {
+ virt_lines = { { { 'a', 'Comment' } } },
+ })
+
+ screen:expect(noextmarks)
+
+ api.nvim_win_add_ns(0, ns)
+
+ screen:expect {
+ grid = [[
+ 1234^5 |
+ {1:a} |
+ {2:~ }|*7
+ |
+ ]]}
+
+ command 'split'
+ command 'only'
+
+ screen:expect(noextmarks)
+ end)
+
+ pending('sign_text', function()
+ -- TODO(altermo): The window signcolumn width is calculated wrongly (when `signcolumn=auto`)
+ -- This happens in function `win_redraw_signcols` on line containing `buf_meta_total(buf, kMTMetaSignText) > 0`
+ set_scoped_extmark(0, 0, {
+ sign_text = 'a',
+ sign_hl_group = 'Comment',
+ })
+
+ screen:expect(noextmarks)
+
+ api.nvim_win_add_ns(0, ns)
+
+ screen:expect {
+ grid = [[
+ a 1234^5 |
+ {2:~ }|*8
+ |
+ ]]}
+
+ command 'split'
+ command 'only'
+
+ screen:expect(noextmarks)
+ end)
+
+ it('statuscolumn hl group', function()
+ local attrs = screen:get_default_attr_ids()
+ table.insert(attrs, {
+ foreground = Screen.colors.Brown,
+ })
+ screen:set_default_attr_ids(attrs)
+
+ set_scoped_extmark(0, 0, {
+ number_hl_group='comment',
+ })
+ set_scoped_extmark(0, 0, {
+ line_hl_group='comment',
+ })
+
+ command 'set number'
+
+ screen:expect {
+ grid = [[
+ {3: 1 }1234^5 |
+ {2:~ }|*8
+ |
+ ]]}
+
+ api.nvim_win_add_ns(0, ns)
+
+ screen:expect {
+ grid = [[
+ {1: 1 1234^5 }|
+ {2:~ }|*8
+ |
+ ]]}
+
+ command 'split'
+ command 'only'
+
+ screen:expect {
+ grid = [[
+ {3: 1 }1234^5 |
+ {2:~ }|*8
+ |
+ ]]}
+ end)
+
+ it('spell', function()
+ local attrs = screen:get_default_attr_ids()
+ table.insert(attrs, {
+ special = Screen.colors.Red, undercurl = true
+ })
+ screen:set_default_attr_ids(attrs)
+ api.nvim_buf_set_lines(0,0,-1,true,{'aa'})
+
+ set_scoped_extmark(0, 0, {
+ spell=true,
+ end_col=2,
+ })
+
+ command 'set spelloptions=noplainbuffer'
+ command 'set spell'
+ command 'syntax off'
+
+ screen:expect {
+ grid = [[
+ a^a |
+ {2:~ }|*8
+ |
+ ]]}
+
+ api.nvim_win_add_ns(0, ns)
+
+ screen:expect {
+ grid = [[
+ {3:a^a} |
+ {2:~ }|*8
+ |
+ ]]}
+
+ command 'split'
+ command 'only'
+
+ screen:expect {
+ grid = [[
+ a^a |
+ {2:~ }|*8
+ |
+ ]]}
+ end)
+
+ it('url', function()
+ local url = 'https://example.com'
+ local attrs = screen:get_default_attr_ids()
+ table.insert(attrs, {
+ url = url,
+ })
+ screen:set_default_attr_ids(attrs)
+
+ set_scoped_extmark(0, 0, {
+ end_col=3,
+ url=url,
+ })
+
+ screen:expect(noextmarks)
+
+ api.nvim_win_add_ns(0, ns)
+
+ screen:expect {
+ grid = [[
+ {3:123}4^5 |
+ {2:~ }|*8
+ |
+ ]]}
+
+ command 'split'
+ command 'only'
+
+ screen:expect(noextmarks)
+ end)
+
+ it('change extmarks scoped option', function()
+ local id = set_scoped_extmark(0, 0, {
+ hl_group = 'Comment',
+ end_col = 3,
+ })
+
+ api.nvim_win_add_ns(0, ns)
+
+ screen:expect {
+ grid = [[
+ {1:123}4^5 |
+ {2:~ }|*8
+ |
+ ]]}
+
+ command 'split'
+ command 'only'
+
+ screen:expect(noextmarks)
+
+ api.nvim_buf_set_extmark(0, ns, 0, 0, {
+ id = id,
+ hl_group = 'Comment',
+ end_col = 3,
+ scoped = false,
+ })
+
+ screen:expect {
+ grid = [[
+ {1:123}4^5 |
+ {2:~ }|*8
+ |
+ ]]}
+
+ api.nvim_buf_set_extmark(0, ns, 0, 0, {
+ id = id,
+ hl_group = 'Comment',
+ end_col = 3,
+ scoped = true,
+ })
+
+ screen:expect(noextmarks)
+ end)
+
+ it('change namespace scope', function()
+ set_scoped_extmark(0, 0, {
+ hl_group = 'Comment',
+ end_col = 3,
+ })
+
+ api.nvim_win_add_ns(0, ns)
+
+ screen:expect {
+ grid = [[
+ {1:123}4^5 |
+ {2:~ }|*8
+ |
+ ]]}
+
+ command 'split'
+ command 'only'
+
+ screen:expect(noextmarks)
+
+ api.nvim_win_add_ns(0, ns)
+
+ screen:expect {
+ grid = [[
+ {1:123}4^5 |
+ {2:~ }|*8
+ |
+ ]]}
+
+ eq(true, api.nvim_win_remove_ns(0, ns))
+ eq({}, api.nvim_win_get_ns(0))
+
+ screen:expect(noextmarks)
+ end)
+end)