config-neovim/lua/plugins/neo-tree.lua

55 lines
1.7 KiB
Lua

return {
"nvim-neo-tree/neo-tree.nvim",
dependencies = {
{ "nvim-lua/plenary.nvim", lazy = true },
{ "nvim-tree/nvim-web-devicons", lazy = true },
{ "MunifTanjim/nui.nvim", lazy = true },
},
cmd = "Neotree",
opts = function()
local git_available = vim.fn.executable("git") == 1
local get_icon = require("nvim-web-devicons").get_icon
local opts = {
filesystem = {
filtered_items = {
visible = true,
},
},
enable_git_status = git_available,
auto_clean_after_session_restore = true,
close_if_last_window = true,
sources = { "filesystem", "buffers", "git_status" },
source_selector = {
winbar = true,
content_layout = "center",
sources = {
{ source = "filesystem", display_name = " 󰉓 Files " },
{ source = "buffers", display_name = " 󰈚 Bufs " },
{ source = "git_status", display_name = " 󰊢 Git " },
},
},
window = {
width = 30,
mappings = {
["[b"] = "prev_source",
["]b"] = "next_source",
}
},
}
return opts
end,
keys = {
{ "<leader>e", "<cmd>Neotree toggle<cr>", desc = "Toggle explorer"},
{
"<leader>o",
function()
if vim.bo.filetype == "neo-tree" then
vim.cmd.wincmd("p")
else
vim.cmd.Neotree("focus")
end
end,
desc = "Toggle explorer"},
},
}