aboutsummaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua')
-rw-r--r--lua/config/nvim-tree.lua2
-rw-r--r--lua/custom-autocmd.lua20
2 files changed, 21 insertions, 1 deletions
diff --git a/lua/config/nvim-tree.lua b/lua/config/nvim-tree.lua
index 4171f1b..6bf653d 100644
--- a/lua/config/nvim-tree.lua
+++ b/lua/config/nvim-tree.lua
@@ -4,8 +4,8 @@ local nvim_tree = require("nvim-tree")
nvim_tree.setup {
auto_reload_on_write = true,
disable_netrw = false,
- hijack_cursor = false,
hijack_netrw = true,
+ hijack_cursor = false,
hijack_unnamed_buffer_when_opening = false,
open_on_tab = false,
sort_by = "name",
diff --git a/lua/custom-autocmd.lua b/lua/custom-autocmd.lua
index 83a1a48..21fa15c 100644
--- a/lua/custom-autocmd.lua
+++ b/lua/custom-autocmd.lua
@@ -83,3 +83,23 @@ api.nvim_create_autocmd("VimResized", {
desc = "autoresize windows on resizing operation",
command = "wincmd =",
})
+
+local function open_nvim_tree(data)
+ -- check if buffer is a directory
+ local directory = vim.fn.isdirectory(data.file) == 1
+
+ if not directory then
+ return
+ end
+
+ -- create a new, empty buffer
+ vim.cmd.enew()
+
+ -- wipe the directory buffer
+ vim.cmd.bw(data.buf)
+
+ -- open the tree
+ require("nvim-tree.api").tree.open()
+end
+
+vim.api.nvim_create_autocmd({ "VimEnter" }, { callback = open_nvim_tree })