Add opt to don't open tree on specific filetypes
This commit is contained in:
parent
b285257876
commit
c59831a5d1
@ -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
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user