refactor: show neo tree if starting nim with directory

This commit is contained in:
Dinesh Salunke 2023-06-26 23:21:10 +05:30
parent c2b0435618
commit 5c17f9b01d

View File

@ -19,3 +19,19 @@ vim.api.nvim_create_autocmd({ "BufWritePre" }, {
vim.fn.mkdir(vim.fn.fnamemodify(file, ":p:h"), "p")
end,
})
vim.api.nvim_create_autocmd("BufEnter", {
desc = "Open Neo-tree on startup with directory",
group = augroup("neo_tree_start"),
callback = function()
if package.loaded["neo-tree"] then
vim.api.nvim_del_augroup_by_name("lazyvim_neo_tree_start")
else
local status = vim.loop.fs_stat(vim.api.nvim_buf_get_name(0))
if status and status.type == "directory" then
vim.api.nvim_del_augroup_by_name("lazyvim_neo_tree_start")
require("neo-tree")
end
end
end,
})