File tree Expand file tree Collapse file tree 5 files changed +42
-0
lines changed Expand file tree Collapse file tree 5 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ Plug 'kyazdani42/nvim-tree.lua'
2020let g:nvim_tree_side = 'right' | 'left' "left by default
2121let g:nvim_tree_width = 40 "30 by default
2222let g:nvim_tree_ignore = [ '.git', 'node_modules', '.cache' ] "empty by default
23+ let g:nvim_tree_gitignore = 2 "0 by default
2324let g:nvim_tree_auto_open = 1 "0 by default, opens the tree when typing `vim $DIR` or `vim`
2425let g:nvim_tree_auto_close = 1 "0 by default, closes the tree when it's the last window
2526let g:nvim_tree_auto_ignore_ft = {'startify', 'dashboard'} "empty by default, don't auto open tree on specific filetypes.
Original file line number Diff line number Diff line change @@ -68,6 +68,17 @@ useful to hide large data/cache folders.
6868>
6969 example: let g:nvim_tree_ignore = [ '.git', 'node_modules' ]
7070
71+ | g:nvim_tree_gitignore | *g:nvim_tree_gitignore*
72+
73+ Determines whether to include in g:nvim_tree_ignore
74+ files ignored by git.
75+
76+ Must be:
77+ 0: not ignored
78+ 1: ignored files from .gitignore
79+ 2: ignored files from .gitignore and git exclude
80+
81+ >
7182| g:nvim_tree_show_icons | *g:nvim_tree_show_icons*
7283
7384Dictionary, if your terminal or font doesn't support certain unicode
Original file line number Diff line number Diff line change @@ -30,6 +30,10 @@ local function update_root_status(root)
3030 end
3131end
3232
33+ function M .get_path_gitexclude ()
34+ return vim .fn .system (" git config --get core.excludesFile" )
35+ end
36+
3337function M .reload_roots ()
3438 for root , status in pairs (roots ) do
3539 if status ~= not_git then
Original file line number Diff line number Diff line change 100100
101101local function gen_ignore_check ()
102102 local ignore_list = {}
103+
104+ local function add_toignore (path )
105+ local content = utils .read_file (path )
106+ for s in content :gmatch (" [^\r\n ]+" ) do
107+ ignore_list [s ] = true
108+ end
109+ end
110+
111+ if (vim .g .nvim_tree_gitignore or 0 ) > 0 then
112+ add_toignore (' .gitignore' )
113+ end
114+ if (vim .g .nvim_tree_gitignore or 0 ) == 2 then
115+ add_toignore (git .get_path_gitexclude ())
116+ end
117+
103118 if vim .g .nvim_tree_ignore and # vim .g .nvim_tree_ignore > 0 then
104119 for _ , entry in pairs (vim .g .nvim_tree_ignore ) do
105120 ignore_list [entry ] = true
Original file line number Diff line number Diff line change 11local M = {}
2+ local uv = vim .loop -- or require("luv") ? i dont understand
23local api = vim .api
34
45function M .path_to_matching_str (path )
@@ -11,6 +12,16 @@ function M.echo_warning(msg)
1112 api .nvim_command (' echohl None' )
1213end
1314
15+ function M .read_file (path )
16+ local fd = uv .fs_open (path , " r" , 438 )
17+ if not fd then return ' ' end
18+ local stat = uv .fs_fstat (fd )
19+ if not stat then return ' ' end
20+ local data = uv .fs_read (fd , stat .size , 0 )
21+ uv .fs_close (fd )
22+ return data or ' '
23+ end
24+
1425local path_separator = package.config :sub (1 ,1 )
1526function M .path_join (paths )
1627 return table.concat (paths , path_separator )
You can’t perform that action at this time.
0 commit comments