1

Refresh generated nvim config

This commit is contained in:
2024-06-03 21:11:20 +02:00
parent fd506d4921
commit 50723ef645
2114 changed files with 84528 additions and 44473 deletions

View File

@ -0,0 +1,107 @@
pcall(require, "luacov")
local Path = require("plenary.path")
local u = require("tests.utils")
local verify = require("tests.utils.verify")
local run_in_current_command = function(command, expected_tree_node)
local winid = vim.api.nvim_get_current_win()
vim.cmd(command)
verify.window_handle_is(winid)
verify.buf_name_endswith(string.format("neo-tree filesystem [%s]", winid), 1000)
if expected_tree_node then
verify.filesystem_tree_node_is(expected_tree_node, winid)
end
end
local run_close_command = function(command)
vim.cmd(command)
u.wait_for(function() end, { interval = 200, timeout = 200 })
end
describe("Command", function()
local test = u.fs.init_test({
items = {
{
name = "foo",
type = "dir",
items = {
{
name = "bar",
type = "dir",
items = {
{ name = "baz1.txt", type = "file" },
{ name = "baz2.txt", type = "file", id = "deepfile2" },
},
},
},
},
{ name = "topfile1.txt", type = "file", id = "topfile1" },
{ name = "topfile2.txt", type = "file", id = "topfile2" },
},
})
test.setup()
local fs_tree = test.fs_tree
after_each(function()
u.clear_environment()
end)
describe("netrw style:", function()
it("`:Neotree current` should show neo-tree in current window", function()
local cmd = "Neotree current"
run_in_current_command(cmd)
end)
it(
"`:Neotree current reveal` should show neo-tree and reveal file in current window",
function()
local cmd = "Neotree current reveal"
local testfile = fs_tree.lookup["topfile1"].abspath
u.editfile(testfile)
run_in_current_command(cmd, testfile)
end
)
it("`:Neotree current reveal toggle` should toggle neo-tree in current window", function()
local cmd = "Neotree current reveal toggle"
local testfile = fs_tree.lookup["topfile1"].abspath
u.editfile(testfile)
local tree_winid = vim.api.nvim_get_current_win()
-- toggle OPEN
run_in_current_command(cmd, testfile)
-- toggle CLOSE
run_close_command(cmd)
verify.window_handle_is(tree_winid)
verify.buf_name_is(testfile)
end)
it(
"`:Neotree current reveal_force_cwd reveal_file=xyz` should reveal file current window if cwd is not a parent of file",
function()
vim.cmd("cd ~")
local testfile = fs_tree.lookup["deepfile2"].abspath
local cmd = "Neotree current reveal_force_cwd reveal_file=" .. testfile
run_in_current_command(cmd, testfile)
end
)
it(
"`:Neotree current reveal_force_cwd reveal_file=xyz` should reveal file current window if cwd is a parent of file",
function()
local testfile = fs_tree.lookup["deepfile2"].abspath
local testfile_dir = Path:new(testfile):parent().filename
vim.cmd(string.format("cd %s", testfile_dir))
local cmd = "Neotree current reveal_force_cwd reveal_file=" .. testfile
run_in_current_command(cmd, testfile)
end
)
end)
test.teardown()
end)

View File

@ -0,0 +1,214 @@
pcall(require, "luacov")
local u = require("tests.utils")
local verify = require("tests.utils.verify")
local run_focus_command = function(command, expected_tree_node)
local winid = vim.api.nvim_get_current_win()
vim.cmd(command)
u.wait_for_neo_tree({ interval = 10, timeout = 200 })
--u.wait_for_neo_tree()
verify.window_handle_is_not(winid)
verify.buf_name_endswith("neo-tree filesystem [1]")
if expected_tree_node then
verify.filesystem_tree_node_is(expected_tree_node)
end
end
local run_show_command = function(command, expected_tree_node)
local starting_winid = vim.api.nvim_get_current_win()
local starting_bufname = vim.api.nvim_buf_get_name(0)
local expected_num_windows = #vim.api.nvim_list_wins() + 1
vim.cmd(command)
verify.eventually(500, function()
if #vim.api.nvim_list_wins() ~= expected_num_windows then
return false
end
if vim.api.nvim_get_current_win() ~= starting_winid then
return false
end
if vim.api.nvim_buf_get_name(0) ~= starting_bufname then
return false
end
if expected_tree_node then
verify.filesystem_tree_node_is(expected_tree_node)
end
return true
end, "Expected to see a new window without focusing it.")
end
local run_close_command = function(command)
vim.cmd(command)
u.wait_for(function() end, { interval = 200, timeout = 200 })
end
describe("Command", function()
local test = u.fs.init_test({
items = {
{
name = "foo",
type = "dir",
items = {
{
name = "bar",
type = "dir",
items = {
{ name = "baz1.txt", type = "file" },
{ name = "baz2.txt", type = "file", id = "deepfile2" },
},
},
{ name = "foofile1.txt", type = "file" },
},
},
{ name = "topfile1.txt", type = "file", id = "topfile1" },
},
})
test.setup()
local fs_tree = test.fs_tree
after_each(function()
u.clear_environment()
end)
describe("with reveal:", function()
it("`:Neotree float reveal` should reveal the current file in the floating window", function()
local cmd = "Neotree float reveal"
local testfile = fs_tree.lookup["./foo/bar/baz1.txt"].abspath
u.editfile(testfile)
run_focus_command(cmd, testfile)
end)
it("`:Neotree reveal toggle` should toggle the reveal-state of the tree", function()
local cmd = "Neotree reveal toggle"
local testfile = fs_tree.lookup["./foo/foofile1.txt"].abspath
u.editfile(testfile)
-- toggle OPEN
run_focus_command(cmd, testfile)
local tree_winid = vim.api.nvim_get_current_win()
-- toggle CLOSE
run_close_command(cmd)
verify.window_handle_is_not(tree_winid)
verify.buf_name_is(testfile)
-- toggle OPEN with a different file
testfile = fs_tree.lookup["./foo/bar/baz1.txt"].abspath
u.editfile(testfile)
run_focus_command(cmd, testfile)
end)
it(
"`:Neotree float reveal toggle` should toggle the reveal-state of the floating window",
function()
local cmd = "Neotree float reveal toggle"
local testfile = fs_tree.lookup["./foo/foofile1.txt"].abspath
u.editfile(testfile)
-- toggle OPEN
run_focus_command(cmd, testfile)
local tree_winid = vim.api.nvim_get_current_win()
-- toggle CLOSE
run_close_command("Neotree float reveal toggle")
verify.window_handle_is_not(tree_winid)
verify.buf_name_is(testfile)
-- toggle OPEN
testfile = fs_tree.lookup["./foo/bar/baz2.txt"].abspath
u.editfile(testfile)
run_focus_command(cmd, testfile)
end
)
it("`:Neotree reveal` should reveal the current file in the sidebar", function()
local cmd = "Neotree reveal"
local testfile = fs_tree.lookup["topfile1"].abspath
u.editfile(testfile)
run_focus_command(cmd, testfile)
end)
end)
for _, follow_current_file in ipairs({ true, false }) do
require("neo-tree").setup({
filesystem = {
follow_current_file = {
enabled = follow_current_file,
},
},
})
describe(string.format("w/ follow_current_file.enabled=%s", follow_current_file), function()
describe("with show :", function()
it("`:Neotree show` should show the window without focusing", function()
local cmd = "Neotree show"
local testfile = fs_tree.lookup["topfile1"].abspath
u.editfile(testfile)
run_show_command(cmd)
end)
it("`:Neotree show toggle` should retain the focused node on next show", function()
local cmd = "Neotree show toggle"
local topfile = fs_tree.lookup["topfile1"].abspath
local baz = fs_tree.lookup["./foo/bar/baz1.txt"].abspath
-- focus a sub node to see if state is retained
u.editfile(baz)
run_focus_command(":Neotree reveal", baz)
local expected_tree_node = baz
verify.after(500, function()
-- toggle CLOSE
run_close_command(cmd)
-- toggle OPEN
u.editfile(topfile)
if follow_current_file then
expected_tree_node = topfile
end
run_show_command(cmd, expected_tree_node)
return true
end)
end)
end)
describe("with focus :", function()
it("`:Neotree focus` should show the window and focus it", function()
local cmd = "Neotree focus"
local testfile = fs_tree.lookup["topfile1"].abspath
u.editfile(testfile)
run_focus_command(cmd)
end)
it("`:Neotree focus toggle` should retain the focused node on next focus", function()
local cmd = "Neotree focus toggle"
local topfile = fs_tree.lookup["topfile1"].abspath
local baz = fs_tree.lookup["./foo/bar/baz1.txt"].abspath
-- focus a sub node to see if state is retained
u.editfile(baz)
run_focus_command("Neotree reveal", baz)
local expected_tree_node = baz
-- toggle CLOSE
run_close_command(cmd)
verify.after(500, function()
-- toggle OPEN
u.editfile(topfile)
if follow_current_file then
expected_tree_node = topfile
end
run_focus_command(cmd, expected_tree_node)
return true
end)
end)
end)
end)
end
test.teardown()
end)

View File

@ -0,0 +1,28 @@
pcall(require, "luacov")
describe("Event queue", function()
it("should return data when handled = true", function()
local events = require("neo-tree.events")
events.subscribe({
event = "test",
handler = function()
return { data = "first" }
end,
})
events.subscribe({
event = "test",
handler = function()
return { handled = true, data = "second" }
end,
})
events.subscribe({
event = "test",
handler = function()
return { data = "third" }
end,
})
local result = events.fire_event("test") or {}
local data = result.data
assert.are.same("second", data)
end)
end)

View File

@ -0,0 +1,146 @@
pcall(require, "luacov")
local ns_id = require("neo-tree.ui.highlights").ns_id
local u = require("tests.utils")
local config = {
renderers = {
directory = {
{
"container",
content = {
{ "indent", zindex = 10 },
{ "icon", zindex = 10 },
{ "name", zindex = 10 },
{ "name", zindex = 5, align = "right" },
},
},
},
file = {
{
"container",
content = {
{ "indent", zindex = 10 },
{ "icon", zindex = 10 },
{ "name", zindex = 10 },
{ "name", zindex = 20, align = "right" },
},
},
},
},
window = {
width = 40,
},
}
local config_right = {
renderers = {
directory = {
{
"container",
enable_character_fade = false,
content = {
{ "indent", zindex = 10, align = "right" },
{ "icon", zindex = 10, align = "right" },
{ "name", zindex = 10, align = "right" },
},
},
},
file = {
{
"container",
enable_character_fade = false,
content = {
{ "indent", zindex = 10, align = "right" },
{ "icon", zindex = 10, align = "right" },
{ "name", zindex = 10, align = "right" },
},
},
},
},
window = {
width = 40,
},
}
local test_dir = {
items = {
{
name = "foo",
type = "dir",
items = {
{
name = "bar",
type = "dir",
items = {
{ name = "bar1.txt", type = "file" },
{ name = "bar2.txt", type = "file" },
},
},
{ name = "foo1.lua", type = "file" },
},
},
{ name = "bazbazbazbazbazbazbazbazbazbazbazbazbazbazbazbazbaz", type = "dir" },
{ name = "1.md", type = "file" },
},
}
describe("sources/components/container", function()
local req_switch = u.get_require_switch()
local test = u.fs.init_test(test_dir)
test.setup()
after_each(function()
if req_switch then
req_switch.restore()
end
u.clear_environment()
end)
describe("should expand to width", function()
for pow = 4, 8 do
it(2 ^ pow, function()
config.window.width = 2 ^ pow
require("neo-tree").setup(config)
vim.cmd([[Neotree focus]])
u.wait_for(function()
return vim.bo.filetype == "neo-tree"
end)
assert.equals(vim.bo.filetype, "neo-tree")
local width = vim.api.nvim_win_get_width(0)
local lines = vim.api.nvim_buf_get_lines(0, 2, -1, false)
for _, line in ipairs(lines) do
assert.is_true(#line >= width)
end
end)
end
end)
describe("right-align should matches width", function()
for pow = 4, 8 do
it(2 ^ pow, function()
config_right.window.width = 2 ^ pow
require("neo-tree").setup(config_right)
vim.cmd([[Neotree focus]])
u.wait_for(function()
return vim.bo.filetype == "neo-tree"
end)
assert.equals(vim.bo.filetype, "neo-tree")
local width = vim.api.nvim_win_get_width(0)
local lines = vim.api.nvim_buf_get_lines(0, 1, -1, false)
for _, line in ipairs(lines) do
line = vim.fn.trim(line, " ", 2)
assert.equals(width, vim.fn.strchars(line))
end
end)
end
end)
test.teardown()
end)

View File

@ -0,0 +1,89 @@
pcall(require, "luacov")
local u = require("tests.utils")
local verify = require("tests.utils.verify")
describe("Filesystem netrw hijack", function()
after_each(function()
u.clear_environment()
end)
it("does not interfere with netrw when disabled", function()
require("neo-tree").setup({
filesystem = {
hijack_netrw_behavior = "disabled",
window = {
position = "left",
},
},
})
vim.cmd("edit .")
assert(#vim.api.nvim_list_wins() == 1, "there should only be one window")
verify.after(100, function()
local name = vim.api.nvim_buf_get_name(0)
return name ~= "neo-tree filesystem [1]"
end, "the buffer should not be neo-tree")
end)
it("opens in sidebar when behavior is open_default", function()
local file = "Makefile"
vim.cmd("edit " .. file)
require("neo-tree").setup({
filesystem = {
hijack_netrw_behavior = "open_default",
window = {
position = "left",
},
},
})
vim.cmd("edit .")
verify.eventually(200, function()
return #vim.api.nvim_list_wins() == 2
end, "there should be two windows")
verify.buf_name_endswith("neo-tree filesystem [1]")
verify.eventually(100, function()
local expected_buf_name = "Makefile"
local buf_at_2 = vim.api.nvim_win_get_buf(vim.fn.win_getid(2))
local name_at_2 = vim.api.nvim_buf_get_name(buf_at_2)
if name_at_2:sub(-#expected_buf_name) == expected_buf_name then
return true
else
return false
end
end, file .. " is not at window 2")
end)
-- This test is flaky and usually fails in github actions but not always
-- so I'm disabling it for now.
-- TODO: fix this test
--
--it("opens in in splits when behavior is open_current", function()
-- local file = "Makefile"
-- vim.cmd("edit " .. file)
-- require("neo-tree").setup({
-- filesystem = {
-- hijack_netrw_behavior = "open_current",
-- },
-- })
-- assert(#vim.api.nvim_list_wins() == 1, "Test should start with one window")
-- vim.cmd("split .")
-- verify.eventually(200, function()
-- if #vim.api.nvim_list_wins() ~= 2 then
-- return false
-- end
-- return vim.api.nvim_buf_get_option(0, "filetype") == "neo-tree"
-- end, "neotree is not in the second window")
--end)
end)

View File

@ -0,0 +1,125 @@
pcall(require, "luacov")
local u = require("tests.utils")
local verify = require("tests.utils.verify")
local manager = require('neo-tree.sources.manager')
local get_dirs = function(winid)
winid = winid or vim.api.nvim_get_current_win()
local tabnr = vim.api.nvim_tabpage_get_number(vim.api.nvim_win_get_tabpage(winid))
local winnr = vim.api.nvim_win_get_number(winid)
return {
win = vim.fn.getcwd(winnr),
tab = vim.fn.getcwd(-1, tabnr),
global = vim.fn.getcwd(-1, -1),
}
end
local get_state_for_tab = function(tabid)
for _, state in ipairs(manager._get_all_states()) do
if state.tabid == tabid then
return state
end
end
end
local get_tabnr = function(tabid)
return vim.api.nvim_tabpage_get_number(tabid or vim.api.nvim_get_current_tabpage())
end
describe("Manager", function()
local test = u.fs.init_test({
items = {
{
name = "foo",
type = "dir",
items = {
{ name = "foofile1.txt", type = "file" },
},
},
{ name = "topfile1.txt", type = "file", id = "topfile1" },
},
})
test.setup()
local fs_tree = test.fs_tree
-- Just make sure we start all tests in the expected state
before_each(function()
u.eq(1, #vim.api.nvim_list_wins())
u.eq(1, #vim.api.nvim_list_tabpages())
vim.cmd.lcd(fs_tree.abspath)
vim.cmd.tcd(fs_tree.abspath)
vim.cmd.cd(fs_tree.abspath)
end)
after_each(function()
u.clear_environment()
end)
local setup_2_tabs = function()
-- create 2 tabs
local tab1 = vim.api.nvim_get_current_tabpage()
local win1 = vim.api.nvim_get_current_win()
vim.cmd.tabnew()
local tab2 = vim.api.nvim_get_current_tabpage()
local win2 = vim.api.nvim_get_current_win()
u.neq(tab2, tab1)
u.neq(win2, win1)
-- set different directories
vim.api.nvim_set_current_tabpage(tab2)
local base_dir = vim.fn.getcwd()
vim.cmd.tcd('foo')
local new_dir = vim.fn.getcwd()
-- open neo-tree
vim.api.nvim_set_current_tabpage(tab1)
vim.cmd.Neotree('show')
vim.api.nvim_set_current_tabpage(tab2)
vim.cmd.Neotree('show')
return {
tab1 = tab1,
tab2 = tab2,
win1 = win1,
win2 = win2,
tab1_dir = base_dir,
tab2_dir = new_dir,
}
end
it("should respect changed tab cwd", function()
local ctx = setup_2_tabs()
local state1 = get_state_for_tab(ctx.tab1)
local state2 = get_state_for_tab(ctx.tab2)
u.eq(ctx.tab1_dir, manager.get_cwd(state1))
u.eq(ctx.tab2_dir, manager.get_cwd(state2))
end)
it("should have correct tab cwd after tabs order is changed", function()
local ctx = setup_2_tabs()
-- tab numbers should be the same as ids
u.eq(1, get_tabnr(ctx.tab1))
u.eq(2, get_tabnr(ctx.tab2))
-- swap tabs
vim.cmd.tabfirst()
vim.cmd.tabmove('+1')
-- make sure tabs have been swapped
u.eq(2, get_tabnr(ctx.tab1))
u.eq(1, get_tabnr(ctx.tab2))
-- verify that tab dirs are the same as nvim tab cwd
local state1 = get_state_for_tab(ctx.tab1)
local state2 = get_state_for_tab(ctx.tab2)
u.eq(get_dirs(ctx.win1).tab, manager.get_cwd(state1))
u.eq(get_dirs(ctx.win2).tab, manager.get_cwd(state2))
end)
end)

View File

@ -0,0 +1,51 @@
pcall(require, "luacov")
local uv = vim.loop
---Return all sources inside "lua/neo-tree/sources"
---@return string[] # name of sources found
local function find_all_sources()
local base_dir = "lua/neo-tree/sources"
local result = {}
local fd = uv.fs_scandir(base_dir)
while fd do
local name, typ = uv.fs_scandir_next(fd)
if not name then
break
end
if typ == "directory" then
local ok, mod = pcall(require, "neo-tree.sources." .. name)
if ok and mod.name then
result[#result + 1] = name
end
end
end
return result
end
describe("sources.navigate(...: #<nparams>)", function()
it("neo-tree.sources.filesystem.navigate exists", function()
local ok, mod = pcall(require, "neo-tree.sources.filesystem")
assert.is_true(ok)
assert.is_not_nil(mod.navigate)
end)
local filesystem_navigate_nparams =
debug.getinfo(require("neo-tree.sources.filesystem").navigate).nparams
it("neo-tree.sources.filesystem.navigate is a func and has args", function()
assert.is_not_nil(filesystem_navigate_nparams)
assert.is_true(filesystem_navigate_nparams > 0)
end)
for _, source in ipairs(find_all_sources()) do
describe(string.format("Test: %s.navigate", source), function()
it(source .. ".navigate is able to require and exists", function()
local ok, mod = pcall(require, "neo-tree.sources." .. source)
assert.is_true(ok)
assert.is_not_nil(mod.navigate)
end)
it(source .. ".navigate has same num of args as filesystem", function()
local nparams = debug.getinfo(require("neo-tree.sources." .. source).navigate).nparams
assert.are.equal(filesystem_navigate_nparams, nparams)
end)
end)
end
end)

View File

@ -0,0 +1,227 @@
pcall(require, "luacov")
local ns_id = require("neo-tree.ui.highlights").ns_id
local u = require("tests.utils")
describe("ui/icons", function()
local req_switch = u.get_require_switch()
local test = u.fs.init_test({
items = {
{
name = "foo",
type = "dir",
items = {
{
name = "bar",
type = "dir",
items = {
{ name = "bar1.txt", type = "file" },
{ name = "bar2.txt", type = "file" },
},
},
{ name = "foo1.lua", type = "file" },
},
},
{ name = "baz", type = "dir" },
{ name = "1.md", type = "file" },
},
})
test.setup()
local fs_tree = test.fs_tree
after_each(function()
if req_switch then
req_switch.restore()
end
u.clear_environment()
end)
describe("w/ default_config", function()
before_each(function()
require("neo-tree").setup({})
end)
it("works w/o nvim-web-devicons", function()
req_switch.disable_package("nvim-web-devicons")
vim.cmd([[:Neotree focus]])
u.wait_for_neo_tree()
local winid = vim.api.nvim_get_current_win()
local bufnr = vim.api.nvim_win_get_buf(winid)
u.assert_buf_lines(bufnr, {
string.format("  %s", fs_tree.abspath):sub(1, 42),
"  baz",
"  foo",
" * 1.md",
})
vim.api.nvim_win_set_cursor(winid, { 2, 0 })
u.feedkeys("<CR>")
vim.api.nvim_win_set_cursor(winid, { 3, 0 })
u.feedkeys("<CR>")
vim.wait(100)
u.assert_buf_lines(bufnr, {
string.format("  %s", fs_tree.abspath):sub(1, 42),
" 󰉖 baz",
"  foo",
" │  bar",
" └ * foo1.lua",
" * 1.md",
})
u.assert_highlight(bufnr, ns_id, 1, "", "NeoTreeDirectoryIcon")
u.assert_highlight(bufnr, ns_id, 2, "󰉖 ", "NeoTreeDirectoryIcon")
u.assert_highlight(bufnr, ns_id, 4, "", "NeoTreeDirectoryIcon")
u.assert_highlight(bufnr, ns_id, 5, "* ", "NeoTreeFileIcon")
end)
it("works w/ nvim-web-devicons", function()
vim.cmd([[:Neotree focus]])
u.wait_for_neo_tree()
local winid = vim.api.nvim_get_current_win()
local bufnr = vim.api.nvim_win_get_buf(winid)
u.assert_buf_lines(bufnr, {
vim.fn.strcharpart(string.format("  %s", fs_tree.abspath), 0, 40),
"  baz",
"  foo",
"  1.md",
})
vim.api.nvim_win_set_cursor(winid, { 2, 0 })
u.feedkeys("<CR>")
vim.api.nvim_win_set_cursor(winid, { 3, 0 })
u.feedkeys("<CR>")
vim.wait(100)
u.assert_buf_lines(bufnr, {
vim.fn.strcharpart(string.format("  %s", fs_tree.abspath), 0, 40),
" 󰉖 baz",
"  foo",
" │  bar",
" └  foo1.lua",
"  1.md",
})
u.assert_highlight(bufnr, ns_id, 1, "", "NeoTreeDirectoryIcon")
u.assert_highlight(bufnr, ns_id, 2, "󰉖 ", "NeoTreeDirectoryIcon")
u.assert_highlight(bufnr, ns_id, 4, "", "NeoTreeDirectoryIcon")
local extmarks = u.get_text_extmarks(bufnr, ns_id, 5, "")
u.eq(#extmarks, 1)
u.neq(extmarks[1][4].hl_group, "NeoTreeFileIcon")
end)
end)
describe("custom config", function()
local config
before_each(function()
config = {
default_component_configs = {
icon = {
folder_closed = "c",
folder_open = "o",
folder_empty = "e",
default = "f",
highlight = "TestNeoTreeFileIcon",
},
},
}
require("neo-tree").setup(config)
end)
it("works w/o nvim-web-devicons", function()
req_switch.disable_package("nvim-web-devicons")
vim.cmd([[:Neotree focus]])
u.wait_for_neo_tree()
local winid = vim.api.nvim_get_current_win()
local bufnr = vim.api.nvim_win_get_buf(winid)
u.assert_buf_lines(bufnr, {
string.format(" o %s", fs_tree.abspath):sub(1, 40),
" c baz",
" c foo",
" f 1.md",
})
vim.api.nvim_win_set_cursor(winid, { 2, 0 })
u.feedkeys("<CR>")
vim.api.nvim_win_set_cursor(winid, { 3, 0 })
u.feedkeys("<CR>")
vim.wait(100)
u.assert_buf_lines(bufnr, {
string.format(" o %s", fs_tree.abspath):sub(1, 40),
" e baz",
" o foo",
" │ c bar",
" └ f foo1.lua",
" f 1.md",
})
u.assert_highlight(bufnr, ns_id, 1, "o ", "NeoTreeDirectoryIcon")
u.assert_highlight(bufnr, ns_id, 2, "e ", "NeoTreeDirectoryIcon")
u.assert_highlight(bufnr, ns_id, 4, "c ", "NeoTreeDirectoryIcon")
u.assert_highlight(bufnr, ns_id, 5, "f ", config.default_component_configs.icon.highlight)
end)
it("works w/ nvim-web-devicons", function()
vim.cmd([[:Neotree focus]])
u.wait_for_neo_tree()
local winid = vim.api.nvim_get_current_win()
local bufnr = vim.api.nvim_win_get_buf(winid)
u.assert_buf_lines(bufnr, {
vim.fn.strcharpart(string.format(" o %s", fs_tree.abspath), 0, 40),
" c baz",
" c foo",
"  1.md",
})
vim.api.nvim_win_set_cursor(winid, { 2, 0 })
u.feedkeys("<CR>")
vim.api.nvim_win_set_cursor(winid, { 3, 0 })
u.feedkeys("<CR>")
vim.wait(100)
u.assert_buf_lines(bufnr, {
vim.fn.strcharpart(string.format(" o %s", fs_tree.abspath), 0, 40),
" e baz",
" o foo",
" │ c bar",
" └  foo1.lua",
"  1.md",
})
u.assert_highlight(bufnr, ns_id, 1, "o ", "NeoTreeDirectoryIcon")
u.assert_highlight(bufnr, ns_id, 2, "e ", "NeoTreeDirectoryIcon")
u.assert_highlight(bufnr, ns_id, 4, "c ", "NeoTreeDirectoryIcon")
local extmarks = u.get_text_extmarks(bufnr, ns_id, 5, "")
u.eq(#extmarks, 1)
u.neq(extmarks[1][4].hl_group, config.default_component_configs.icon.highlight)
end)
end)
test.teardown()
end)