diff options
Diffstat (limited to 'neovim/.config/nvim/lua/plugins/filetree.lua')
| -rw-r--r-- | neovim/.config/nvim/lua/plugins/filetree.lua | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/neovim/.config/nvim/lua/plugins/filetree.lua b/neovim/.config/nvim/lua/plugins/filetree.lua new file mode 100644 index 0000000..cdee9f7 --- /dev/null +++ b/neovim/.config/nvim/lua/plugins/filetree.lua | |||
| @@ -0,0 +1,33 @@ | |||
| 1 | return { | ||
| 2 | "preservim/nerdtree", | ||
| 3 | lazy = false, | ||
| 4 | config = function() | ||
| 5 | -- Open NERDTree when no file is specified; quit when it's the last window | ||
| 6 | local augroup = vim.api.nvim_create_augroup("nerdtree_auto", { clear = true }) | ||
| 7 | |||
| 8 | vim.api.nvim_create_autocmd("StdinReadPre", { | ||
| 9 | group = augroup, | ||
| 10 | callback = function() | ||
| 11 | vim.g.std_in = 1 | ||
| 12 | end, | ||
| 13 | }) | ||
| 14 | |||
| 15 | vim.api.nvim_create_autocmd("VimEnter", { | ||
| 16 | group = augroup, | ||
| 17 | callback = function() | ||
| 18 | if vim.fn.argc() == 0 and vim.g.std_in == nil then | ||
| 19 | vim.cmd("NERDTree") | ||
| 20 | end | ||
| 21 | end, | ||
| 22 | }) | ||
| 23 | |||
| 24 | vim.api.nvim_create_autocmd("BufEnter", { | ||
| 25 | group = augroup, | ||
| 26 | callback = function() | ||
| 27 | if vim.fn.winnr("$") == 1 and vim.bo.filetype == "nerdtree" then | ||
| 28 | vim.cmd("quit") | ||
| 29 | end | ||
| 30 | end, | ||
| 31 | }) | ||
| 32 | end, | ||
| 33 | } | ||
