11local log = require (" nvim-tree.log" )
2- local appearance = require (" nvim-tree.appearance" )
32local view = require (" nvim-tree.view" )
43local utils = require (" nvim-tree.utils" )
54local actions = require (" nvim-tree.actions" )
@@ -151,19 +150,6 @@ local function setup_autocommands(opts)
151150 vim .api .nvim_create_autocmd (name , vim .tbl_extend (" force" , default_opts , custom_opts ))
152151 end
153152
154- -- reset and draw (highlights) when colorscheme is changed
155- create_nvim_tree_autocmd (" ColorScheme" , {
156- callback = function ()
157- appearance .setup ()
158- view .reset_winhl ()
159-
160- local explorer = core .get_explorer ()
161- if explorer then
162- explorer .renderer :draw ()
163- end
164- end ,
165- })
166-
167153 -- prevent new opened file from opening in the same window as nvim-tree
168154 create_nvim_tree_autocmd (" BufWipeout" , {
169155 pattern = " NvimTree_*" ,
@@ -179,79 +165,9 @@ local function setup_autocommands(opts)
179165 end ,
180166 })
181167
182- create_nvim_tree_autocmd (" BufWritePost" , {
183- callback = function ()
184- if opts .auto_reload_on_write and not opts .filesystem_watchers .enable then
185- local explorer = core .get_explorer ()
186- if explorer then
187- explorer :reload_explorer ()
188- end
189- end
190- end ,
191- })
192-
193- create_nvim_tree_autocmd (" BufReadPost" , {
194- callback = function (data )
195- -- update opened file buffers
196- local explorer = core .get_explorer ()
197- if not explorer then
198- return
199- end
200- if
201- (explorer .filters .config .filter_no_buffer or explorer .opts .highlight_opened_files ~= " none" ) and vim .bo [data .buf ].buftype == " "
202- then
203- utils .debounce (" Buf:filter_buffer" , opts .view .debounce_delay , function ()
204- explorer :reload_explorer ()
205- end )
206- end
207- end ,
208- })
209-
210- create_nvim_tree_autocmd (" BufUnload" , {
211- callback = function (data )
212- -- update opened file buffers
213- local explorer = core .get_explorer ()
214- if not explorer then
215- return
216- end
217- if
218- (explorer .filters .config .filter_no_buffer or explorer .opts .highlight_opened_files ~= " none" ) and vim .bo [data .buf ].buftype == " "
219- then
220- utils .debounce (" Buf:filter_buffer" , opts .view .debounce_delay , function ()
221- explorer :reload_explorer ()
222- end )
223- end
224- end ,
225- })
226-
227- create_nvim_tree_autocmd (" User" , {
228- pattern = { " FugitiveChanged" , " NeogitStatusRefreshed" },
229- callback = function ()
230- if not opts .filesystem_watchers .enable and opts .git .enable then
231- local explorer = core .get_explorer ()
232- if explorer then
233- explorer :reload_git ()
234- end
235- end
236- end ,
237- })
238-
239168 if opts .tab .sync .open then
240169 create_nvim_tree_autocmd (" TabEnter" , { callback = vim .schedule_wrap (M .tab_enter ) })
241170 end
242- if opts .hijack_cursor then
243- create_nvim_tree_autocmd (" CursorMoved" , {
244- pattern = " NvimTree_*" ,
245- callback = function ()
246- if utils .is_nvim_tree_buf (0 ) then
247- local explorer = core .get_explorer ()
248- if explorer then
249- explorer :place_cursor_on_node ()
250- end
251- end
252- end ,
253- })
254- end
255171 if opts .sync_root_with_cwd then
256172 create_nvim_tree_autocmd (" DirChanged" , {
257173 callback = function ()
@@ -277,20 +193,6 @@ local function setup_autocommands(opts)
277193 create_nvim_tree_autocmd ({ " BufEnter" , " BufNewFile" }, { callback = M .open_on_directory })
278194 end
279195
280- create_nvim_tree_autocmd (" BufEnter" , {
281- pattern = " NvimTree_*" ,
282- callback = function ()
283- if utils .is_nvim_tree_buf (0 ) then
284- if vim .fn .getcwd () ~= core .get_cwd () or (opts .reload_on_bufenter and not opts .filesystem_watchers .enable ) then
285- local explorer = core .get_explorer ()
286- if explorer then
287- explorer :reload_explorer ()
288- end
289- end
290- end
291- end ,
292- })
293-
294196 if opts .view .centralize_selection then
295197 create_nvim_tree_autocmd (" BufEnter" , {
296198 pattern = " NvimTree_*" ,
@@ -330,20 +232,6 @@ local function setup_autocommands(opts)
330232 end ,
331233 })
332234 end
333-
334- if opts .modified .enable then
335- create_nvim_tree_autocmd ({ " BufModifiedSet" , " BufWritePost" }, {
336- callback = function ()
337- utils .debounce (" Buf:modified" , opts .view .debounce_delay , function ()
338- require (" nvim-tree.buffers" ).reload_modified ()
339- local explorer = core .get_explorer ()
340- if explorer then
341- explorer :reload_explorer ()
342- end
343- end )
344- end ,
345- })
346- end
347235end
348236
349237local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
@@ -839,6 +727,7 @@ function M.setup(conf)
839727 require (" nvim-tree.appearance" ).setup ()
840728 require (" nvim-tree.diagnostics" ).setup (opts )
841729 require (" nvim-tree.explorer" ):setup (opts )
730+ require (" nvim-tree.explorer.watch" ).setup (opts )
842731 require (" nvim-tree.git" ).setup (opts )
843732 require (" nvim-tree.git.utils" ).setup (opts )
844733 require (" nvim-tree.view" ).setup (opts )
0 commit comments