-
-
Notifications
You must be signed in to change notification settings - Fork 638
Closed
Description
I'm really enjoying this plugin, but I'm stuck trying to figure out how to open the nvim-tree window automatically when opening nvim without focusing on it.
I've been able to toggle nvim-tree without focus using something like this:
function M.show()
require('nvim-tree.view').open({ focus_tree = false })
end
function M.toggle(find_file)
local nvimtree = require 'nvim-tree'
local view = require 'nvim-tree.view'
if view.win_open() then
view.close()
else
if M.setup_config.update_focused_file.enable or find_file then
nvimtree.find_file(true)
end
M.show()
end
end
function M.show_on_startup()
require('nvim-tree').open()
vim.cmd('wincmd p')
-- this wincmd does NOT work and I can't figure out a workaround
-- focus is always on tree after entering vim
end
vim.cmd [[
command! NvimTreeShowToggle lua require'plugins.configs.nvim-tree'.toggle()
command! NvimTreeShowStartup lua require'plugins.configs.nvim-tree'.show_on_startup()
]]
vim.cmd [[
augroup nvimtree
autocmd BufEnter * if (winnr('$') == 1 && &filetype == 'NvimTree') | q | endif
autocmd VimEnter * NvimTreeShowStartup
augroup END
]]
But, no matter what I try, I can't figure out how to get what I want. When I was using CHADTree, I was able to use CHADTree --nofocus. I thought it might be due to other autocommands that the plugin is loading, but disabling them didn't help (assuming I did it correctly).
Metadata
Metadata
Assignees
Labels
No labels