aboutsummaryrefslogtreecommitdiff
path: root/test/functional
diff options
context:
space:
mode:
authorLuuk van Baal <luukvbaal@gmail.com>2024-11-24 14:46:20 +0100
committerluukvbaal <luukvbaal@gmail.com>2025-02-25 13:09:01 +0100
commit8ba047e33fe3a10765c593c810d54b5e3bb906e9 (patch)
treea31efbda695dcae1e1d31c738b72fec5669bf32f /test/functional
parentf58e7d5fac1c4f63f0ba3e59134591239182910e (diff)
downloadrneovim-8ba047e33fe3a10765c593c810d54b5e3bb906e9.tar.gz
rneovim-8ba047e33fe3a10765c593c810d54b5e3bb906e9.tar.bz2
rneovim-8ba047e33fe3a10765c593c810d54b5e3bb906e9.zip
feat(treesitter): vertical conceal support for highlighter
TSHighlighter now places marks for conceal_lines metadata. A new internal decor provider callback _on_conceal_line was added that instructs the highlighter to place conceal_lines marks whenever the editor needs to know whether a line is concealed. The bundled markdown queries use conceal_lines metadata to conceal code block fence lines.
Diffstat (limited to 'test/functional')
-rw-r--r--test/functional/treesitter/highlight_spec.lua107
1 files changed, 104 insertions, 3 deletions
diff --git a/test/functional/treesitter/highlight_spec.lua b/test/functional/treesitter/highlight_spec.lua
index 02b50fd80e..c59160d8c7 100644
--- a/test/functional/treesitter/highlight_spec.lua
+++ b/test/functional/treesitter/highlight_spec.lua
@@ -1152,14 +1152,16 @@ describe('treesitter highlighting (markdown)', function()
})
end)
- it('works with spellchecked and smoothscrolled topline', function()
- insert([[
+ local code_block = [[
- $f(0)=\sum_{k=1}^{\infty}\frac{2}{\pi^{2}k^{2}}+\lim_{w \to 0}x$.
```c
printf('Hello World!');
```
- ]])
+ ]]
+
+ it('works with spellchecked and smoothscrolled topline', function()
+ insert(code_block)
command('set spell smoothscroll')
feed('gg<C-E>')
screen:add_extra_attr_ids({ [100] = { undercurl = true, special = Screen.colors.Red } })
@@ -1174,6 +1176,105 @@ printf('Hello World!');
]],
})
end)
+
+ it('works with concealed lines', function()
+ insert(code_block)
+ screen:expect({
+ grid = [[
+ |
+ {18:```}{15:c} |
+ {25:printf}{16:(}{26:'Hello World!'}{16:);} |
+ {18:```} |
+ ^ |
+ |
+ ]],
+ })
+ feed('ggj')
+ command('set number conceallevel=3')
+ screen:expect({
+ grid = [[
+ {8: 1 }{16:- }$f(0)=\sum_{k=1}^{\infty}\frac{2}{|
+ {8: }\pi^{2}k^{2}}+\lim_{w \to 0}x$. |
+ {8: 2 }^ |
+ {8: 4 }{25:printf}{16:(}{26:'Hello World!'}{16:);} |
+ {8: 6 } |
+ |
+ ]],
+ })
+ feed('j')
+ screen:expect({
+ grid = [[
+ {8: 1 }{16:- }$f(0)=\sum_{k=1}^{\infty}\frac{2}{|
+ {8: }\pi^{2}k^{2}}+\lim_{w \to 0}x$. |
+ {8: 2 } |
+ {8: 3 }{18:^```}{15:c} |
+ {8: 4 }{25:printf}{16:(}{26:'Hello World!'}{16:);} |
+ |
+ ]],
+ })
+ feed('j')
+ screen:expect({
+ grid = [[
+ {8: 1 }{16:- }$f(0)=\sum_{k=1}^{\infty}\frac{2}{|
+ {8: }\pi^{2}k^{2}}+\lim_{w \to 0}x$. |
+ {8: 2 } |
+ {8: 4 }{25:^printf}{16:(}{26:'Hello World!'}{16:);} |
+ {8: 6 } |
+ |
+ ]],
+ })
+ feed('j')
+ screen:expect({
+ grid = [[
+ {8: 1 }{16:- }$f(0)=\sum_{k=1}^{\infty}\frac{2}{|
+ {8: }\pi^{2}k^{2}}+\lim_{w \to 0}x$. |
+ {8: 2 } |
+ {8: 4 }{25:printf}{16:(}{26:'Hello World!'}{16:);} |
+ {8: 5 }{18:^```} |
+ |
+ ]],
+ })
+ -- Concealed lines highlight until changed botline
+ screen:try_resize(screen._width, 16)
+ feed('y3k30P:<Esc><C-F><C-B>')
+ screen:expect([[
+ {8: 1 }{16:- }$f(0)=\sum_{k=1}^{\infty}\frac{2}{|
+ {8: }\pi^{2}k^{2}}+\lim_{w \to 0}x$. |
+ {8: 2 } |
+ {8: 4 }{25:printf}{16:(}{26:'Hello World!'}{16:);} |
+ {8: 6 } |
+ {8: 8 }{25:printf}{16:(}{26:'Hello World!'}{16:);} |
+ {8: 10 } |
+ {8: 12 }{25:printf}{16:(}{26:'Hello World!'}{16:);} |
+ {8: 14 } |
+ {8: 16 }{25:printf}{16:(}{26:'Hello World!'}{16:);} |
+ {8: 18 } |
+ {8: 20 }{25:printf}{16:(}{26:'Hello World!'}{16:);} |
+ {8: 22 } |
+ {8: 24 }{25:printf}{16:(}{26:'Hello World!'}{16:);} |
+ {8: 25 }{18:^```} |
+ |
+ ]])
+ feed('G')
+ screen:expect([[
+ {8: 98 } |
+ {8:100 }{25:printf}{16:(}{26:'Hello World!'}{16:);} |
+ {8:102 } |
+ {8:104 }{25:printf}{16:(}{26:'Hello World!'}{16:);} |
+ {8:106 } |
+ {8:108 }{25:printf}{16:(}{26:'Hello World!'}{16:);} |
+ {8:110 } |
+ {8:112 }{25:printf}{16:(}{26:'Hello World!'}{16:);} |
+ {8:114 } |
+ {8:116 }{25:printf}{16:(}{26:'Hello World!'}{16:);} |
+ {8:118 } |
+ {8:120 }{25:printf}{16:(}{26:'Hello World!'}{16:);} |
+ {8:122 } |
+ {8:124 }{25:printf}{16:(}{26:'Hello World!'}{16:);} |
+ {8:126 } ^ |
+ |
+ ]])
+ end)
end)
it('starting and stopping treesitter highlight in init.lua works #29541', function()