fix(edgy): only enable edgy neo-tree when needed. Fixes #3697. Closes #3703

This commit is contained in:
Folke Lemaitre 2024-06-17 20:06:54 +02:00
parent d9caee6100
commit bdca1e95ff
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040

View file

@ -53,26 +53,7 @@ return {
{ title = "Neotest Output", ft = "neotest-output-panel", size = { height = 15 } }, { title = "Neotest Output", ft = "neotest-output-panel", size = { height = 15 } },
}, },
left = { left = {
{
title = "Neo-Tree",
ft = "neo-tree",
filter = function(buf)
return vim.b[buf].neo_tree_source == "filesystem"
end,
pinned = true,
open = function()
require("neo-tree.command").execute({ dir = LazyVim.root() })
end,
size = { height = 0.5 },
},
{ title = "Neotest Summary", ft = "neotest-summary" }, { title = "Neotest Summary", ft = "neotest-summary" },
{
title = "Neo-Tree Other",
ft = "neo-tree",
filter = function(buf)
return vim.b[buf].neo_tree_source ~= nil
end,
},
-- "neo-tree", -- "neo-tree",
}, },
keys = { keys = {
@ -95,13 +76,26 @@ return {
}, },
} }
if LazyVim.has("neo-tree.nvim") then
table.insert(opts.left, 1, {
title = "Neo-Tree",
ft = "neo-tree",
filter = function(buf)
return vim.b[buf].neo_tree_source == "filesystem"
end,
pinned = true,
open = function()
require("neo-tree.command").execute({ dir = LazyVim.root() })
end,
size = { height = 0.5 },
})
-- only add neo-tree sources if they are enabled in config -- only add neo-tree sources if they are enabled in config
local neotree_opts = LazyVim.opts("neo-tree.nvim") local neotree_opts = LazyVim.opts("neo-tree.nvim")
local neotree_sources = { buffers = "top", git_status = "right" } local neotree_sources = { buffers = "top", git_status = "right" }
for source, pos in pairs(neotree_sources) do for source, pos in pairs(neotree_sources) do
if vim.list_contains(neotree_opts.sources, source) then if vim.list_contains(neotree_opts.sources or {}, source) then
table.insert(opts.left, 3, { table.insert(opts.left, {
title = "Neo-Tree " .. source:gsub("_", " "), title = "Neo-Tree " .. source:gsub("_", " "),
ft = "neo-tree", ft = "neo-tree",
filter = function(buf) filter = function(buf)
@ -112,6 +106,14 @@ return {
}) })
end end
end end
table.insert(opts.left, {
title = "Neo-Tree Other",
ft = "neo-tree",
filter = function(buf)
return vim.b[buf].neo_tree_source ~= nil
end,
})
end
for _, pos in ipairs({ "top", "bottom", "left", "right" }) do for _, pos in ipairs({ "top", "bottom", "left", "right" }) do
opts[pos] = opts[pos] or {} opts[pos] = opts[pos] or {}