1- local api = require (" nvim-tree.api" )
2- local log = require (" nvim-tree.log" )
3- local notify = require (" nvim-tree.notify" )
41local config = require (" nvim-tree.config" )
52
63local M = {}
1916local function setup_autocommands ()
2017 local augroup_id = vim .api .nvim_create_augroup (" NvimTree" , { clear = true })
2118
22- -- prevent new opened file from opening in the same window as nvim-tree
2319 vim .api .nvim_create_autocmd (" BufWipeout" , {
2420 group = augroup_id ,
2521 pattern = " NvimTree_*" ,
2622 callback = function ()
27- if not require (" nvim-tree.utils" ).is_nvim_tree_buf (0 ) then
28- return
29- end
30- local view = require (" nvim-tree.view" )
31- if config .g .actions .open_file .eject then
32- view ._prevent_buffer_override ()
33- else
34- view .abandon_current_window ()
35- end
23+ require (" nvim-tree.view" ).wipeout ()
3624 end ,
3725 })
3826
@@ -44,6 +32,7 @@ local function setup_autocommands()
4432 end )
4533 })
4634 end
35+
4736 if config .g .sync_root_with_cwd then
4837 vim .api .nvim_create_autocmd (" DirChanged" , {
4938 group = augroup_id ,
@@ -52,17 +41,12 @@ local function setup_autocommands()
5241 end ,
5342 })
5443 end
44+
5545 if config .g .update_focused_file .enable then
5646 vim .api .nvim_create_autocmd (" BufEnter" , {
5747 group = augroup_id ,
5848 callback = function (event )
59- local exclude = config .g .update_focused_file .exclude
60- if type (exclude ) == " function" and exclude (event ) then
61- return
62- end
63- require (" nvim-tree.utils" ).debounce (" BufEnter:find_file" , config .g .view .debounce_delay , function ()
64- require (" nvim-tree.actions.tree.find-file" ).fn ()
65- end )
49+ require (" nvim-tree.actions.tree.find-file" ).buf_enter (event )
6650 end ,
6751 })
6852 end
@@ -97,15 +81,14 @@ local function setup_autocommands()
9781 vim .api .nvim_create_autocmd (" DiagnosticChanged" , {
9882 group = augroup_id ,
9983 callback = function (ev )
100- log .line (" diagnostics" , " DiagnosticChanged" )
10184 require (" nvim-tree.diagnostics" ).update_lsp (ev )
10285 end ,
10386 })
87+
10488 vim .api .nvim_create_autocmd (" User" , {
10589 group = augroup_id ,
10690 pattern = " CocDiagnosticChange" ,
10791 callback = function ()
108- log .line (" diagnostics" , " CocDiagnosticChange" )
10992 require (" nvim-tree.diagnostics" ).update_coc ()
11093 end ,
11194 })
145128function M .purge_all_state ()
146129 local view = require (" nvim-tree.view" )
147130 local core = require (" nvim-tree.core" )
131+
148132 view .close_all_tabs ()
149133 view .abandon_all_windows ()
150134 local explorer = core .get_explorer ()
159143
160144--- @param config_user ? nvim_tree.config user supplied subset of config
161145function M .setup (config_user )
146+ local log = require (" nvim-tree.log" )
147+
162148 if vim .fn .has (" nvim-0.9" ) == 0 then
163- notify .warn (" nvim-tree.lua requires Neovim 0.9 or higher" )
149+ require ( " nvim-tree. notify" ) .warn (" nvim-tree.lua requires Neovim 0.9 or higher" )
164150 return
165151 end
166152
@@ -189,7 +175,7 @@ function M.setup(config_user)
189175 vim .g .NvimTreeSetup = 1
190176 vim .api .nvim_exec_autocmds (" User" , { pattern = " NvimTreeSetup" })
191177
192- require (" nvim-tree.api.impl" ).hydrate_post_setup (api )
178+ require (" nvim-tree.api.impl" ).hydrate_post_setup (require ( " nvim-tree. api" ) )
193179end
194180
195181vim .g .NvimTreeRequired = 1
0 commit comments