refactor(extras.ui): simplify neo-tree related logic in edgy extra (#3738)

Refactor neo-tree related logic

## What is this PR for?
Simplification of `neo-tree` related logic in `edgy.lua`

## Does this PR fix an existing issue?
No, but it may prevent future issues with `edgy` if `neo-tree` source
configuration changes.

## Checklist

- [x] I've read the
[CONTRIBUTING](https://github.com/LazyVim/LazyVim/blob/main/CONTRIBUTING.md)
guidelines.
This commit is contained in:
Gobinda Goshwami 2024-06-23 11:08:41 +06:00 committed by GitHub
parent b45d4ed62c
commit 19e366277b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -77,42 +77,27 @@ return {
} }
if LazyVim.has("neo-tree.nvim") then if LazyVim.has("neo-tree.nvim") then
table.insert(opts.left, 1, { local pos = {
title = "Neo-Tree", filesystem = "left",
ft = "neo-tree", buffers = "top",
filter = function(buf) git_status = "right",
return vim.b[buf].neo_tree_source == "filesystem" document_symbols = "bottom",
end, diagnostics = "bottom",
pinned = true, }
open = function() local sources = LazyVim.opts("neo-tree.nvim").sources or {}
require("neo-tree.command").execute({ dir = LazyVim.root() }) for i, v in ipairs(sources) do
end, table.insert(opts.left, i, {
size = { height = 0.5 }, title = "Neo-Tree " .. v:gsub("_", " "):gsub("^%l", string.upper),
}) ft = "neo-tree",
-- only add neo-tree sources if they are enabled in config filter = function(buf)
local neotree_opts = LazyVim.opts("neo-tree.nvim") return vim.b[buf].neo_tree_source == v
local neotree_sources = { buffers = "top", git_status = "right" } end,
pinned = true,
for source, pos in pairs(neotree_sources) do open = function()
if vim.list_contains(neotree_opts.sources or {}, source) then vim.cmd(("Neotree show position=%s %s dir=%s"):format(pos[v] or "bottom", v, LazyVim.root()))
table.insert(opts.left, { end,
title = "Neo-Tree " .. source:gsub("_", " "), })
ft = "neo-tree",
filter = function(buf)
return vim.b[buf].neo_tree_source == source
end,
pinned = true,
open = "Neotree position=" .. pos .. " " .. source,
})
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 end
for _, pos in ipairs({ "top", "bottom", "left", "right" }) do for _, pos in ipairs({ "top", "bottom", "left", "right" }) do