11local log = require (" nvim-tree.log" )
2- local view = require (" nvim-tree.view" )
32local utils = require (" nvim-tree.utils" )
43local actions = require (" nvim-tree.actions" )
54local core = require (" nvim-tree.core" )
@@ -74,7 +73,8 @@ function M.change_root(path, bufnr)
7473end
7574
7675function M .tab_enter ()
77- if view .is_visible ({ any_tabpage = true }) then
76+ local explorer = core .get_explorer ()
77+ if explorer and explorer .view :is_visible ({ any_tabpage = true }) then
7878 local bufname = vim .api .nvim_buf_get_name (0 )
7979
8080 local ft
@@ -89,17 +89,15 @@ function M.tab_enter()
8989 return
9090 end
9191 end
92- view . open ({ focus_tree = false })
92+ explorer . view : open ({ focus_tree = false })
9393
94- local explorer = core .get_explorer ()
95- if explorer then
96- explorer .renderer :draw ()
97- end
94+ explorer .renderer :draw ()
9895 end
9996end
10097
10198function M .open_on_directory ()
102- local should_proceed = _config .hijack_directories .auto_open or view .is_visible ()
99+ local explorer = core .get_explorer ()
100+ local should_proceed = _config .hijack_directories .auto_open or explorer and explorer .view :is_visible ()
103101 if not should_proceed then
104102 return
105103 end
@@ -150,21 +148,6 @@ local function setup_autocommands(opts)
150148 vim .api .nvim_create_autocmd (name , vim .tbl_extend (" force" , default_opts , custom_opts ))
151149 end
152150
153- -- prevent new opened file from opening in the same window as nvim-tree
154- create_nvim_tree_autocmd (" BufWipeout" , {
155- pattern = " NvimTree_*" ,
156- callback = function ()
157- if not utils .is_nvim_tree_buf (0 ) then
158- return
159- end
160- if opts .actions .open_file .eject then
161- view ._prevent_buffer_override ()
162- else
163- view .abandon_current_window ()
164- end
165- end ,
166- })
167-
168151 if opts .tab .sync .open then
169152 create_nvim_tree_autocmd (" TabEnter" , { callback = vim .schedule_wrap (M .tab_enter ) })
170153 end
@@ -226,17 +209,6 @@ local function setup_autocommands(opts)
226209 })
227210 end
228211
229- if opts .view .float .enable and opts .view .float .quit_on_focus_loss then
230- create_nvim_tree_autocmd (" WinLeave" , {
231- pattern = " NvimTree_*" ,
232- callback = function ()
233- if utils .is_nvim_tree_buf (0 ) then
234- view .close ()
235- end
236- end ,
237- })
238- end
239-
240212 -- Handles event dispatch when tree is closed by `:q`
241213 create_nvim_tree_autocmd (" WinClosed" , {
242214 pattern = " *" ,
@@ -513,6 +485,7 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
513485 },
514486 },
515487 experimental = {
488+ multi_instance = false ,
516489 },
517490 log = {
518491 enable = false ,
@@ -692,10 +665,10 @@ local function localise_default_opts()
692665end
693666
694667function M .purge_all_state ()
695- view .close_all_tabs ()
696- view .abandon_all_windows ()
697668 local explorer = core .get_explorer ()
698669 if explorer then
670+ explorer .view :close_all_tabs ()
671+ explorer .view :abandon_all_windows (" purge_all_state" )
699672 require (" nvim-tree.git" ).purge_state ()
700673 explorer :destroy ()
701674 core .reset_explorer ()
@@ -748,12 +721,12 @@ function M.setup(conf)
748721 require (" nvim-tree.explorer.watch" ).setup (opts )
749722 require (" nvim-tree.git" ).setup (opts )
750723 require (" nvim-tree.git.utils" ).setup (opts )
751- require (" nvim-tree.view" ).setup (opts )
752724 require (" nvim-tree.lib" ).setup (opts )
753725 require (" nvim-tree.renderer.components" ).setup (opts )
754726 require (" nvim-tree.buffers" ).setup (opts )
755727 require (" nvim-tree.help" ).setup (opts )
756728 require (" nvim-tree.watcher" ).setup (opts )
729+ require (" nvim-tree.multi-instance-debug" ).setup (opts )
757730
758731 setup_autocommands (opts )
759732
0 commit comments