irongit

A readme explaining how to make neovim work fast

hygo-vim/lua/plugins/nvim-tree.lua
32 lines884 BLua
1return {
2 "nvim-tree/nvim-tree.lua",
3 enabled = false,
4 config = function()
5 local nvim_tree = require("nvim-tree")
6 local api = require("nvim-tree.api")
7
8 -- Setup first
9 nvim_tree.setup()
10
11 -- Track last known root
12 local last_root = vim.fn.getcwd()
13 vim.api.nvim_create_autocmd("BufEnter", {
14 pattern = "NvimTree_*",
15 callback = function()
16 local root = api.tree.get_root()
17 if root and root.absolute_path then
18 last_root = root.absolute_path
19 vim.notify("move root to " .. last_root)
20 end
21 end,
22 })
23 -- -- Smart toggle with saved root
24 -- vim.keymap.set("n", "<leader>e", function()
25 -- if api.tree.is_visible() then
26 -- api.tree.close()
27 -- else
28 -- api.tree.open({ path = last_root })
29 -- end
30 -- end, { desc = "Toggle Nvim-Tree at last location" })
31 end,
32}