diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 00000000..eec2b9c5 Binary files /dev/null and b/.DS_Store differ diff --git a/README.md b/README.md index 9815721a..7d37637a 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ let g:nvim_tree_width = 40 "30 by default let g:nvim_tree_ignore = [ '.git', 'node_modules', '.cache' ] "empty by default let g:nvim_tree_auto_open = 1 "0 by default, opens the tree when typing `vim $DIR` or `vim` let g:nvim_tree_auto_close = 1 "0 by default, closes the tree when it's the last window +let g:nvim_tree_auto_ignore_ft = {'startify', 'dashboard'} "empty by default, don't auto open tree on specific filetypes. let g:nvim_tree_quit_on_open = 1 "0 by default, closes the tree when you open a file let g:nvim_tree_follow = 1 "0 by default, this option allows the cursor to be updated when entering a buffer let g:nvim_tree_indent_markers = 1 "0 by default, this option shows indent markers when folders are open diff --git a/doc/nvim-tree-lua.txt b/doc/nvim-tree-lua.txt index 5491f8a9..4adba18f 100644 --- a/doc/nvim-tree-lua.txt +++ b/doc/nvim-tree-lua.txt @@ -70,7 +70,7 @@ useful to hide large data/cache folders. |g:nvim_tree_show_icons| *g:nvim_tree_show_icons* -Dictionnary, if your terminal or font doesn't support certain unicode +Dictionary, if your terminal or font doesn't support certain unicode character, the tree UI might be messed up. The following configuration can disable icons per type: > @@ -135,6 +135,14 @@ Can be `0` or `1`. When `1`, will bind |BufEnter| to automatically close the tree if it's the last window. Default is 0 +|g:nvim_tree_auto_ignore_ft| *g:nvim_tree_auto_ignore_ft* + +Don't auto open the tree on specific filetypes. +Useful when you don't want to open tree on plugins like 'Startify' +Default is {} +> + example: let g.nvim_tree_auto_ignore_ft = {'startify', 'dashboard'} + |g:nvim_tree_quit_on_open| *g:nvim_tree_quit_on_open* Can be `0` or `1`. When `1`, will close the tree when a file is opened. diff --git a/lua/nvim-tree.lua b/lua/nvim-tree.lua index 3137d2c8..c3ac7044 100644 --- a/lua/nvim-tree.lua +++ b/lua/nvim-tree.lua @@ -119,13 +119,17 @@ end function M.on_enter() local bufnr = api.nvim_get_current_buf() local bufname = api.nvim_buf_get_name(bufnr) + local buftype = api.nvim_buf_get_option(bufnr, 'filetype') + local ft_ignore = vim.g.nvim_tree_auto_ignore_ft or {} local stats = luv.fs_stat(bufname) local is_dir = stats and stats.type == 'directory' if is_dir then api.nvim_command('cd '..bufname) end - local should_open = vim.g.nvim_tree_auto_open == 1 and (bufname == '' or is_dir) + local should_open = vim.g.nvim_tree_auto_open == 1 and + (bufname == '' or is_dir) and + not vim.tbl_contains(ft_ignore, buftype) colors.setup() lib.init(should_open, should_open) end