You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
628 B
Lua
24 lines
628 B
Lua
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]
|
|
local no_name = data.file == "" and vim.bo[data.buf].buftype == ""
|
|
|
|
if not real_file and not no_name then
|
|
return
|
|
end
|
|
|
|
-- open the tree, find the file but don't focus it
|
|
require("nvim-tree.api").tree.toggle({ focus = false, find_file = true, })
|
|
end
|
|
|
|
-- Auto open
|
|
vim.api.nvim_create_autocmd({ "VimEnter" }, { callback = open_nvim_tree })
|
|
|
|
-- Auto close
|
|
vim.api.nvim_create_autocmd({"QuitPre"}, {
|
|
callback = function() vim.cmd("NvimTreeClose") end,
|
|
})
|