Files
nvim/lua/plugins/neo-tree.lua
2025-07-25 12:32:22 +01:00

59 lines
1.8 KiB
Lua

-- Neo-tree is a Neovim plugin to browse the file system
-- https://github.com/nvim-neo-tree/neo-tree.nvim
return {
'nvim-neo-tree/neo-tree.nvim',
version = '*',
dependencies = {
'nvim-lua/plenary.nvim',
'nvim-tree/nvim-web-devicons', -- not strictly required, but recommended
'MunifTanjim/nui.nvim',
},
cmd = 'Neotree',
keys = {
{ '\\', ':Neotree reveal<CR>', desc = 'NeoTree reveal', silent = true },
},
build = function()
if vim.fn.executable 'fd' == 0 then
local install_cmd
if vim.fn.has 'mac' == 1 then
install_cmd = 'brew install fd'
elseif vim.fn.has 'unix' == 1 then
if vim.fn.filereadable '/etc/arch-release' == 1 then
install_cmd = 'sudo pacman -S --noconfirm fd'
else
install_cmd = 'sudo apt-get install -y fd-find'
end
else
vim.notify("Please install 'fd' manually for neo-tree.", vim.log.levels.WARN)
return
end
vim.fn.system(install_cmd)
end
end,
opts = function(_, opts)
local function on_move(data)
Snacks.rename.on_rename_file(data.source, data.destination)
end
local events = require 'neo-tree.events'
opts.event_handlers = opts.event_handlers or {}
vim.list_extend(opts.event_handlers, {
{ event = events.FILE_MOVED, handler = on_move },
{ event = events.FILE_RENAMED, handler = on_move },
})
opts.filesystem = {
window = {
mappings = {
['\\'] = 'close_window',
},
},
filtered_items = {
hide_dotfiles = false,
},
}
end,
}