Don't open nvim tree on file, only on empty start

This commit is contained in:
Evie Litherland-Smith 2023-02-13 10:35:17 +00:00
parent 771f611e3a
commit 10a5b10085

View file

@ -51,19 +51,15 @@ require('nvim-tree').setup {
} }
local function open_nvim_tree(data) local function open_nvim_tree(data)
-- buffer is a real file on the disk
local real_file = vim.fn.filereadable(data.file) == 1
-- buffer is a [No Name] -- buffer is a [No Name]
local no_name = data.file == "" and vim.bo[data.buf].buftype == "" local no_name = data.file == "" and vim.bo[data.buf].buftype == ""
if not real_file and not no_name then if not no_name then
return return
end end
-- open the tree, find the file but don't focus it -- open the tree, find the file but don't focus it
require("nvim-tree.api").tree.toggle({ focus = false, find_file = true, }) require("nvim-tree.api").tree.toggle({ focus = false })
end end
vim.api.nvim_create_autocmd({ "VimEnter" }, { callback = open_nvim_tree }) vim.api.nvim_create_autocmd({ "VimEnter" }, { callback = open_nvim_tree })