Did you check docs and existing issues?
Neovim Version (nvim -v)
NVIM v0.12.1
Operating System / Version
Windows 11 25H2 / Ubuntu 24.04.4 LTS
Describe the Bug
When Neotree is open in a window with source A (e.g. buffers) and the cursor is currently in another window, a :Neotree toggle filesystem does switch the source to filesystem`, but does not bring that window in focus (i.e. move the cursor there).
The same is true for :Neotree reveal.
The following change fixes it for me (with all tests still passing and based on my testing other behaviour staying as expected) and I can create a PR with that change, but I am not entirely sure whether manager.navigate is actually expected to always navigate to state.winid (a call a few lines above somewhat indicates that).
diff --git a/lua/neo-tree/command/init.lua b/lua/neo-tree/command/init.lua
index 3c3145a..0a7a688 100644
--- a/lua/neo-tree/command/init.lua
+++ b/lua/neo-tree/command/init.lua
@@ -48,7 +48,11 @@ local function do_show_or_focus(args, state, force_navigate)
end
if force_navigate or not window_exists then
-- close_other_sources()
- manager.navigate(state, args.dir, args.reveal_file, nil, false)
+ manager.navigate(state, args.dir, args.reveal_file, function()
+ if state.winid and vim.api.nvim_win_is_valid(state.winid) then
+ vim.api.nvim_set_current_win(state.winid)
+ end
+ end, false)
end
end
end
Screenshots, Traceback
No response
Steps to Reproduce
- Open Neovim (config see below)
:Neotree reveal filesystem
<C-w>l (move to another window)
:Neotree toggle buffers or :Neotree reveal buffers (the buffer displays the buffers, but it the cursor is not in the neotree window)
Expected Behavior
The Neotree buffer gets focus
Your Configuration
-- template from https://lazy.folke.io/developers#reprolua, feel free to replace if you have your own minimal init.lua
vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()
require("lazy.minit").repro({
spec = {
{
"nvim-neo-tree/neo-tree.nvim",
branch = "main"
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-tree/nvim-web-devicons", -- not strictly required, but recommended
"MunifTanjim/nui.nvim",
},
lazy = false,
---@module "neo-tree"
---@type neotree.Config?
opts = {},
}
},
})
vim.g.mapleader = " "
vim.keymap.set("n", "<leader>e", "<Cmd>Neotree<CR>")
-- do anything else you need to do to reproduce the issue
Did you check docs and existing issues?
Neovim Version (nvim -v)
NVIM v0.12.1
Operating System / Version
Windows 11 25H2 / Ubuntu 24.04.4 LTS
Describe the Bug
When Neotree is open in a window with source A (e.g.
buffers) and the cursor is currently in another window, a:Neotree toggle filesystemdoes switch thesource tofilesystem`, but does not bring that window in focus (i.e. move the cursor there).The same is true for
:Neotree reveal.The following change fixes it for me (with all tests still passing and based on my testing other behaviour staying as expected) and I can create a PR with that change, but I am not entirely sure whether
manager.navigateis actually expected to always navigate tostate.winid(a call a few lines above somewhat indicates that).Screenshots, Traceback
No response
Steps to Reproduce
:Neotree reveal filesystem<C-w>l(move to another window):Neotree toggle buffersor:Neotree reveal buffers(the buffer displays the buffers, but it the cursor is not in the neotree window)Expected Behavior
The Neotree buffer gets focus
Your Configuration