nvim-tree.lua
nvim-tree.lua copied to clipboard
FindFile but not focus the tree
Is it possible to run NvimTreeFindFile but keep the focus on the file buffer, i..e, not focus on the tree automatically? Thank you so much.
~:NvimTreeFindFile | wincmd p ?~
doesn't seem to work :smile: there is no such functionnality in nvim-tree but i believe you can achieve this with a bit of scripting :)
function find_file_no_focus()
require "nvim-tree".find_file()
vim.cmd "wincmd p"
end
or something like that
Yes. This is exactly what I came up with. Do you think whether it will be better to add a boolean argument for find_file() like find_file(..., no_focus) as toggle() does to control "focus or not"? Thanks.
I know this does not exactly fit your requirement, however update_focused_file.enable will focus the tree on the file buffer without changing focus.
@rockyzhang24 i think it could make sense yes :)
Is there any progress with this? Suggested options don't work I keep getting
Error detected while processing VimEnter Autocommands for "*":
Error executing Lua callback: ...fig/nvim/bundle/nvim-tree.lua/lua/nvim-tree/git/init.lua:99: table index is nil
stack traceback:
...fig/nvim/bundle/nvim-tree.lua/lua/nvim-tree/git/init.lua:99: in function 'load_project_status'
...vim/bundle/nvim-tree.lua/lua/nvim-tree/explorer/init.lua:28: in function '_load'
...vim/bundle/nvim-tree.lua/lua/nvim-tree/explorer/init.lua:22: in function 'new'
....config/nvim/bundle/nvim-tree.lua/lua/nvim-tree/core.lua:15: in function 'init'
.../.config/nvim/bundle/nvim-tree.lua/lua/nvim-tree/lib.lua:98: in function 'open'
...quad/.config/nvim/bundle/nvim-tree.lua/lua/nvim-tree.lua:94: in function 'open'
...quad/.config/nvim/bundle/nvim-tree.lua/lua/nvim-tree.lua:293: in function <...quad/.config/nvim/bundle/nvim-tree.lua/lua/nvim-tree.lua:292>
Press ENTER or type command to continue
But the future would help a lot.
A proper solution with find_file(..., no_focus) would be best.
PRs gratefully accepted :)
Tracked at #2011