mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 11:58:17 +00:00
revert: "feat(treesitter): add foldtext with treesitter highlighting"
This reverts commit 9ce1623
in favor of #20750.
This commit is contained in:
@@ -675,126 +675,3 @@ t2]])
|
||||
}
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('treesitter foldtext', function()
|
||||
local test_text = [[
|
||||
void qsort(void *base, size_t nel, size_t width, int (*compar)(const void *, const void *))
|
||||
{
|
||||
int width = INT_MAX, height = INT_MAX;
|
||||
bool ext_widgets[kUIExtCount];
|
||||
for (UIExtension i = 0; (int)i < kUIExtCount; i++) {
|
||||
ext_widgets[i] = true;
|
||||
}
|
||||
|
||||
bool inclusive = ui_override();
|
||||
for (size_t i = 0; i < ui_count; i++) {
|
||||
UI *ui = uis[i];
|
||||
width = MIN(ui->width, width);
|
||||
height = MIN(ui->height, height);
|
||||
foo = BAR(ui->bazaar, bazaar);
|
||||
for (UIExtension j = 0; (int)j < kUIExtCount; j++) {
|
||||
ext_widgets[j] &= (ui->ui_ext[j] || inclusive);
|
||||
}
|
||||
}
|
||||
}]]
|
||||
local screen
|
||||
|
||||
before_each(function()
|
||||
screen = Screen.new(60, 5)
|
||||
screen:set_default_attr_ids({
|
||||
[0] = { foreground = Screen.colors.Blue, bold = true },
|
||||
[1] = { foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGray },
|
||||
[2] = {
|
||||
bold = true,
|
||||
background = Screen.colors.LightGray,
|
||||
foreground = Screen.colors.SeaGreen,
|
||||
},
|
||||
[3] = { foreground = Screen.colors.DarkCyan, background = Screen.colors.LightGray },
|
||||
[4] = { foreground = Screen.colors.SlateBlue, background = Screen.colors.LightGray },
|
||||
[5] = { bold = true, background = Screen.colors.LightGray, foreground = Screen.colors.Brown },
|
||||
[6] = { background = Screen.colors.Red1 },
|
||||
[7] = { foreground = Screen.colors.DarkBlue, background = Screen.colors.Red },
|
||||
[8] = { foreground = Screen.colors.Brown, bold = true, background = Screen.colors.Red },
|
||||
[9] = { foreground = Screen.colors.SlateBlue, background = Screen.colors.Red },
|
||||
[10] = { bold = true },
|
||||
})
|
||||
screen:attach()
|
||||
end)
|
||||
|
||||
it('displays highlighted content', function()
|
||||
command([[set foldmethod=manual foldtext=v:lua.vim.treesitter.foldtext() updatetime=50]])
|
||||
insert(test_text)
|
||||
exec_lua([[vim.treesitter.get_parser(0, "c")]])
|
||||
|
||||
feed('ggVGzf')
|
||||
screen:expect {
|
||||
grid = [[
|
||||
{4:^void}{1: }{3:qsort}{4:(void}{1: }{5:*}{3:base}{4:,}{1: }{4:size_t}{1: }{3:nel}{4:,}{1: }{4:size_t}{1: }{3:width}{4:,}{1: }{4:int}{1: }{4:(}{5:*}{3:compa}|
|
||||
{0:~ }|*3
|
||||
|
|
||||
]],
|
||||
}
|
||||
end)
|
||||
|
||||
it('handles deep nested captures', function()
|
||||
command([[set foldmethod=manual foldtext=v:lua.vim.treesitter.foldtext() updatetime=50]])
|
||||
insert([[
|
||||
function FoldInfo.new()
|
||||
return setmetatable({
|
||||
start_counts = {},
|
||||
stop_counts = {},
|
||||
levels0 = {},
|
||||
levels = {},
|
||||
}, FoldInfo)
|
||||
end]])
|
||||
exec_lua([[vim.treesitter.get_parser(0, "lua")]])
|
||||
|
||||
feed('ggjVGkzfgg')
|
||||
screen:expect {
|
||||
grid = [[
|
||||
^function FoldInfo.new() |
|
||||
{1: }{5:return}{1: }{4:setmetatable({}{1:·····································}|
|
||||
end |
|
||||
{0:~ }|
|
||||
|
|
||||
]],
|
||||
}
|
||||
|
||||
command('hi! Visual guibg=Red')
|
||||
feed('GVgg')
|
||||
screen:expect {
|
||||
grid = [[
|
||||
^f{6:unction FoldInfo.new()} |
|
||||
{7: }{8:return}{7: }{9:setmetatable({}{7:·····································}|
|
||||
{6:end} |
|
||||
{0:~ }|
|
||||
{10:-- VISUAL LINE --} |
|
||||
]],
|
||||
}
|
||||
|
||||
feed('10l<C-V>')
|
||||
screen:expect {
|
||||
grid = [[
|
||||
{6:function F}^oldInfo.new() |
|
||||
{7: }{8:return}{7: }{9:se}{4:tmetatable({}{1:·····································}|
|
||||
{6:end} |
|
||||
{0:~ }|
|
||||
{10:-- VISUAL BLOCK --} |
|
||||
]],
|
||||
}
|
||||
end)
|
||||
|
||||
it('falls back to default', function()
|
||||
command([[set foldmethod=manual foldtext=v:lua.vim.treesitter.foldtext()]])
|
||||
insert(test_text)
|
||||
|
||||
feed('ggVGzf')
|
||||
screen:expect {
|
||||
grid = [[
|
||||
{1:^+-- 19 lines: void qsort(void *base, size_t nel, size_t widt}|
|
||||
{0:~ }|*3
|
||||
|
|
||||
]],
|
||||
}
|
||||
end)
|
||||
end)
|
||||
|
Reference in New Issue
Block a user