1
1
local log = require (" nvim-tree.log" )
2
- local view = require (" nvim-tree.view" )
3
2
local utils = require (" nvim-tree.utils" )
4
3
local actions = require (" nvim-tree.actions" )
5
4
local core = require (" nvim-tree.core" )
@@ -74,7 +73,8 @@ function M.change_root(path, bufnr)
74
73
end
75
74
76
75
function 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
78
78
local bufname = vim .api .nvim_buf_get_name (0 )
79
79
80
80
local ft
@@ -89,17 +89,15 @@ function M.tab_enter()
89
89
return
90
90
end
91
91
end
92
- view . open ({ focus_tree = false })
92
+ explorer . view : open ({ focus_tree = false })
93
93
94
- local explorer = core .get_explorer ()
95
- if explorer then
96
- explorer .renderer :draw ()
97
- end
94
+ explorer .renderer :draw ()
98
95
end
99
96
end
100
97
101
98
function 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 ()
103
101
if not should_proceed then
104
102
return
105
103
end
@@ -150,21 +148,6 @@ local function setup_autocommands(opts)
150
148
vim .api .nvim_create_autocmd (name , vim .tbl_extend (" force" , default_opts , custom_opts ))
151
149
end
152
150
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
-
168
151
if opts .tab .sync .open then
169
152
create_nvim_tree_autocmd (" TabEnter" , { callback = vim .schedule_wrap (M .tab_enter ) })
170
153
end
@@ -226,17 +209,6 @@ local function setup_autocommands(opts)
226
209
})
227
210
end
228
211
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
-
240
212
-- Handles event dispatch when tree is closed by `:q`
241
213
create_nvim_tree_autocmd (" WinClosed" , {
242
214
pattern = " *" ,
@@ -513,6 +485,7 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
513
485
},
514
486
},
515
487
experimental = {
488
+ multi_instance = false ,
516
489
},
517
490
log = {
518
491
enable = false ,
@@ -692,10 +665,10 @@ local function localise_default_opts()
692
665
end
693
666
694
667
function M .purge_all_state ()
695
- view .close_all_tabs ()
696
- view .abandon_all_windows ()
697
668
local explorer = core .get_explorer ()
698
669
if explorer then
670
+ explorer .view :close_all_tabs ()
671
+ explorer .view :abandon_all_windows (" purge_all_state" )
699
672
require (" nvim-tree.git" ).purge_state ()
700
673
explorer :destroy ()
701
674
core .reset_explorer ()
@@ -748,12 +721,12 @@ function M.setup(conf)
748
721
require (" nvim-tree.explorer.watch" ).setup (opts )
749
722
require (" nvim-tree.git" ).setup (opts )
750
723
require (" nvim-tree.git.utils" ).setup (opts )
751
- require (" nvim-tree.view" ).setup (opts )
752
724
require (" nvim-tree.lib" ).setup (opts )
753
725
require (" nvim-tree.renderer.components" ).setup (opts )
754
726
require (" nvim-tree.buffers" ).setup (opts )
755
727
require (" nvim-tree.help" ).setup (opts )
756
728
require (" nvim-tree.watcher" ).setup (opts )
729
+ require (" nvim-tree.multi-instance-debug" ).setup (opts )
757
730
758
731
setup_autocommands (opts )
759
732
0 commit comments