Replies: 5 comments 4 replies
-
Basically, i'm looking for an option for |
Beta Was this translation helpful? Give feedback.
-
Are you talking about the filesystem source or the buffers source? |
Beta Was this translation helpful? Give feedback.
-
You have |
Beta Was this translation helpful? Give feedback.
-
Hmm I really can't reproduce. Could you add this to your init.lua and live for a while? vim.api.nvim_create_autocmd("DirChanged", {
callback = function(...)
vim.print(string.format([[Dir Changed (%s): %s]], vim.fn.getcwd(), vim.inspect({ ... })))
end,
}) |
Beta Was this translation helpful? Give feedback.
-
EDIT: I found some more discussions (#885, #1411). Seems like the solution is to use I am also curious if there is a way to show all open buffers, not just the buffers open in the current project. I am using LazyVim. The setup in LazyVim is given at the bottom of this post for reference. The issue I am experiencing is as follows: I'm not sure if this behavior is caused by the other plugins/configurations in LazyVim, so I am curious if this is expected behavior. I would match rather the output just show OPEN BUFFERS and not have it be specific to the current root/project/cwd, but that's just me. {
"nvim-neo-tree/neo-tree.nvim",
branch = "v3.x",
cmd = "Neotree",
keys = {
{
"<leader>fe",
function()
require("neo-tree.command").execute({ toggle = true, dir = LazyVim.root() })
end,
desc = "Explorer NeoTree (Root Dir)",
},
{
"<leader>fE",
function()
require("neo-tree.command").execute({ toggle = true, dir = vim.uv.cwd() })
end,
desc = "Explorer NeoTree (cwd)",
},
{ "<leader>e", "<leader>fe", desc = "Explorer NeoTree (Root Dir)", remap = true },
{ "<leader>E", "<leader>fE", desc = "Explorer NeoTree (cwd)", remap = true },
{
"<leader>ge",
function()
require("neo-tree.command").execute({ source = "git_status", toggle = true })
end,
desc = "Git Explorer",
},
{
"<leader>be",
function()
require("neo-tree.command").execute({ source = "buffers", toggle = true })
end,
desc = "Buffer Explorer",
},
},
deactivate = function()
vim.cmd([[Neotree close]])
end,
init = function()
-- FIX: use `autocmd` for lazy-loading neo-tree instead of directly requiring it,
-- because `cwd` is not set up properly.
vim.api.nvim_create_autocmd("BufEnter", {
group = vim.api.nvim_create_augroup("Neotree_start_directory", { clear = true }),
desc = "Start Neo-tree with directory",
once = true,
callback = function()
if package.loaded["neo-tree"] then
return
else
local stats = vim.uv.fs_stat(vim.fn.argv(0))
if stats and stats.type == "directory" then
require("neo-tree")
end
end
end,
})
end,
opts = {
sources = { "filesystem", "buffers", "git_status", "document_symbols" },
open_files_do_not_replace_types = { "terminal", "Trouble", "trouble", "qf", "Outline" },
filesystem = {
bind_to_cwd = false,
follow_current_file = { enabled = true },
use_libuv_file_watcher = true,
},
window = {
mappings = {
["l"] = "open",
["h"] = "close_node",
["<space>"] = "none",
["Y"] = {
function(state)
local node = state.tree:get_node()
local path = node:get_id()
vim.fn.setreg("+", path, "c")
end,
desc = "Copy Path to Clipboard",
},
["O"] = {
function(state)
require("lazy.util").open(state.tree:get_node().path, { system = true })
end,
desc = "Open with System Application",
},
["P"] = { "toggle_preview", config = { use_float = false } },
},
},
default_component_configs = {
indent = {
with_expanders = true, -- if nil and file nesting is enabled, will enable expanders
expander_collapsed = "",
expander_expanded = "",
expander_highlight = "NeoTreeExpander",
},
git_status = {
symbols = {
unstaged = "",
staged = "",
},
},
},
},
config = function(_, opts)
local function on_move(data)
LazyVim.lsp.on_rename(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 },
})
require("neo-tree").setup(opts)
vim.api.nvim_create_autocmd("TermClose", {
pattern = "*lazygit",
callback = function()
if package.loaded["neo-tree.sources.git_status"] then
require("neo-tree.sources.git_status").refresh()
end
end,
})
end,
} |
Beta Was this translation helpful? Give feedback.
-
Hi!
Thanks for the plugin, it looks very nice and so far proved to be the most convenient of all the alternatives!
One thing that is bothering me though - I would like to see the list of all open buffers, not the buffers for files in the "current directory". The problem is - if I open Neovim in
~/repo/project1
, thenneo-tree
will happily show all open buffers under the directory. If at some point I do:e ../project2/file.txt
, then openingneo-tree
won't even show that file, since it will still be listing the files under~/repo/project1
.If I run with
dir=/
, to include all possible directories in the tree (because I can runnvim
anywhere in the filesystem), then it works fine for a while, but at some point typing:e <TAB>
starts showing the root of the filesystem, which is not what I'd expect it to do. I wrote "for a while" because the behavior is inconsistent and for some time:e <TAB>
correctly shows the "current directory", but then it all of a sudden switches to/
.Can someone give a hint how to fix this? It would be great to have a setup where the tree lists all open buffers, nicely grouped by their parent directories, regardless of the "current project directory" but with
:e
pointing to it?Thanks!
Beta Was this translation helpful? Give feedback.
All reactions