@@ -36,7 +36,7 @@ function M.change_root(path, bufnr)
3636 ft = vim .api .nvim_buf_get_option (bufnr , " filetype" ) or " " --- @diagnostic disable-line : deprecated
3737 end
3838
39- for _ , value in pairs (config .current () .update_focused_file .update_root .ignore_list ) do
39+ for _ , value in pairs (config .g .update_focused_file .update_root .ignore_list ) do
4040 if utils .str_find (path , value ) or utils .str_find (ft , value ) then
4141 return
4242 end
@@ -68,12 +68,12 @@ function M.change_root(path, bufnr)
6868 end
6969
7070 -- otherwise test M.init_root
71- if config .current () .prefer_startup_root and utils .path_relative (path , M .init_root ) ~= path then
71+ if config .g .prefer_startup_root and utils .path_relative (path , M .init_root ) ~= path then
7272 explorer_fn (" change_dir" , M .init_root )
7373 return
7474 end
7575 -- otherwise root_dirs
76- for _ , dir in pairs (config .current () .root_dirs ) do
76+ for _ , dir in pairs (config .g .root_dirs ) do
7777 dir = vim .fn .fnamemodify (dir , " :p" )
7878 if utils .path_relative (path , dir ) ~= path then
7979 explorer_fn (" change_dir" , dir )
@@ -95,7 +95,7 @@ function M.tab_enter()
9595 ft = vim .api .nvim_buf_get_option (0 , " ft" ) --- @diagnostic disable-line : deprecated
9696 end
9797
98- for _ , filter in ipairs (config .current () .tab .sync .ignore ) do
98+ for _ , filter in ipairs (config .g .tab .sync .ignore ) do
9999 if bufname :match (filter ) ~= nil or ft :match (filter ) ~= nil then
100100 return
101101 end
@@ -110,7 +110,7 @@ function M.tab_enter()
110110end
111111
112112function M .open_on_directory ()
113- local should_proceed = config .current () .hijack_directories .auto_open or view .is_visible ()
113+ local should_proceed = config .g .hijack_directories .auto_open or view .is_visible ()
114114 if not should_proceed then
115115 return
116116 end
@@ -131,11 +131,11 @@ function M.open_on_directory()
131131end
132132
133133local function manage_netrw ()
134- if config .current () .hijack_netrw then
134+ if config .g .hijack_netrw then
135135 vim .cmd (" silent! autocmd! FileExplorer *" )
136136 vim .cmd (" autocmd VimEnter * ++once silent! autocmd! FileExplorer *" )
137137 end
138- if config .current () .disable_netrw then
138+ if config .g .disable_netrw then
139139 vim .g .loaded_netrw = 1
140140 vim .g .loaded_netrwPlugin = 1
141141 end
@@ -147,7 +147,7 @@ function M.change_dir(name)
147147 explorer_fn (" change_dir" , name )
148148 end
149149
150- if config .current () .update_focused_file .update_root .enable then
150+ if config .g .update_focused_file .update_root .enable then
151151 actions .tree .find_file .fn ()
152152 end
153153end
@@ -166,43 +166,43 @@ local function setup_autocommands()
166166 if not utils .is_nvim_tree_buf (0 ) then
167167 return
168168 end
169- if config .current () .actions .open_file .eject then
169+ if config .g .actions .open_file .eject then
170170 view ._prevent_buffer_override ()
171171 else
172172 view .abandon_current_window ()
173173 end
174174 end ,
175175 })
176176
177- if config .current () .tab .sync .open then
177+ if config .g .tab .sync .open then
178178 create_nvim_tree_autocmd (" TabEnter" , { callback = vim .schedule_wrap (M .tab_enter ) })
179179 end
180- if config .current () .sync_root_with_cwd then
180+ if config .g .sync_root_with_cwd then
181181 create_nvim_tree_autocmd (" DirChanged" , {
182182 callback = function ()
183183 M .change_dir (vim .loop .cwd ())
184184 end ,
185185 })
186186 end
187- if config .current () .update_focused_file .enable then
187+ if config .g .update_focused_file .enable then
188188 create_nvim_tree_autocmd (" BufEnter" , {
189189 callback = function (event )
190- local exclude = config .current () .update_focused_file .exclude
190+ local exclude = config .g .update_focused_file .exclude
191191 if type (exclude ) == " function" and exclude (event ) then
192192 return
193193 end
194- utils .debounce (" BufEnter:find_file" , config .current () .view .debounce_delay , function ()
194+ utils .debounce (" BufEnter:find_file" , config .g .view .debounce_delay , function ()
195195 actions .tree .find_file .fn ()
196196 end )
197197 end ,
198198 })
199199 end
200200
201- if config .current () .hijack_directories .enable and (config .current () .disable_netrw or config .current () .hijack_netrw ) then
201+ if config .g .hijack_directories .enable and (config .g .disable_netrw or config .g .hijack_netrw ) then
202202 create_nvim_tree_autocmd ({ " BufEnter" , " BufNewFile" }, { callback = M .open_on_directory , nested = true })
203203 end
204204
205- if config .current () .view .centralize_selection then
205+ if config .g .view .centralize_selection then
206206 create_nvim_tree_autocmd (" BufEnter" , {
207207 pattern = " NvimTree_*" ,
208208 callback = function ()
@@ -219,7 +219,7 @@ local function setup_autocommands()
219219 })
220220 end
221221
222- if config .current () .diagnostics .enable then
222+ if config .g .diagnostics .enable then
223223 create_nvim_tree_autocmd (" DiagnosticChanged" , {
224224 callback = function (ev )
225225 log .line (" diagnostics" , " DiagnosticChanged" )
@@ -235,7 +235,7 @@ local function setup_autocommands()
235235 })
236236 end
237237
238- if config .current () .view .float .enable and config .current () .view .float .quit_on_focus_loss then
238+ if config .g .view .float .enable and config .g .view .float .quit_on_focus_loss then
239239 create_nvim_tree_autocmd (" WinLeave" , {
240240 pattern = " NvimTree_*" ,
241241 callback = function ()
@@ -278,41 +278,41 @@ end
278278-- TODO #3253 ensure that we can call setup twice
279279
280280
281- --- @param conf ? nvim_tree.config
282- function M .setup (conf )
281+ --- @param config_user ? nvim_tree.config user supplied subset of config
282+ function M .setup (config_user )
283283 if vim .fn .has (" nvim-0.9" ) == 0 then
284284 notify .warn (" nvim-tree.lua requires Neovim 0.9 or higher" )
285285 return
286286 end
287287
288288 M .init_root = vim .fn .getcwd ()
289289
290- config .setup (conf )
290+ config .setup (config_user )
291291
292292 manage_netrw ()
293293
294- require (" nvim-tree.notify" ).setup (config .current () )
295- require (" nvim-tree.log" ).setup (config .current () )
294+ require (" nvim-tree.notify" ).setup (config .g )
295+ require (" nvim-tree.log" ).setup (config .g )
296296
297297 if log .enabled (" config" ) then
298298 log .line (" config" , " default config + user" )
299- log .raw (" config" , " %s\n " , vim .inspect (config .current () ))
299+ log .raw (" config" , " %s\n " , vim .inspect (config .g ))
300300 end
301301
302- require (" nvim-tree.actions" ).setup (config .current () )
303- require (" nvim-tree.keymap" ).setup (config .current () )
302+ require (" nvim-tree.actions" ).setup (config .g )
303+ require (" nvim-tree.keymap" ).setup (config .g )
304304 require (" nvim-tree.appearance" ).setup ()
305- require (" nvim-tree.diagnostics" ).setup (config .current () )
306- require (" nvim-tree.explorer" ):setup (config .current () )
307- require (" nvim-tree.explorer.watch" ).setup (config .current () )
308- require (" nvim-tree.git" ).setup (config .current () )
309- require (" nvim-tree.git.utils" ).setup (config .current () )
310- require (" nvim-tree.view" ).setup (config .current () )
311- require (" nvim-tree.lib" ).setup (config .current () )
312- require (" nvim-tree.renderer.components" ).setup (config .current () )
313- require (" nvim-tree.buffers" ).setup (config .current () )
314- require (" nvim-tree.help" ).setup (config .current () )
315- require (" nvim-tree.watcher" ).setup (config .current () )
305+ require (" nvim-tree.diagnostics" ).setup (config .g )
306+ require (" nvim-tree.explorer" ):setup (config .g )
307+ require (" nvim-tree.explorer.watch" ).setup (config .g )
308+ require (" nvim-tree.git" ).setup (config .g )
309+ require (" nvim-tree.git.utils" ).setup (config .g )
310+ require (" nvim-tree.view" ).setup (config .g )
311+ require (" nvim-tree.lib" ).setup (config .g )
312+ require (" nvim-tree.renderer.components" ).setup (config .g )
313+ require (" nvim-tree.buffers" ).setup (config .g )
314+ require (" nvim-tree.help" ).setup (config .g )
315+ require (" nvim-tree.watcher" ).setup (config .g )
316316
317317 setup_autocommands ()
318318
0 commit comments