File tree Expand file tree Collapse file tree 2 files changed +16
-13
lines changed
Expand file tree Collapse file tree 2 files changed +16
-13
lines changed Original file line number Diff line number Diff line change @@ -2,17 +2,6 @@ local config = require("nvim-tree.config")
22
33local M = {}
44
5- local function manage_netrw ()
6- if config .g .hijack_netrw then
7- vim .cmd (" silent! autocmd! FileExplorer *" )
8- vim .cmd (" autocmd VimEnter * ++once silent! autocmd! FileExplorer *" )
9- end
10- if config .g .disable_netrw then
11- vim .g .loaded_netrw = 1
12- vim .g .loaded_netrwPlugin = 1
13- end
14- end
15-
165local function setup_autocommands ()
176 local augroup_id = vim .api .nvim_create_augroup (" NvimTree" , { clear = true })
187
@@ -152,8 +141,6 @@ function M.setup(config_user)
152141
153142 config .setup (config_user )
154143
155- manage_netrw ()
156-
157144 log .start ()
158145
159146 if log .enabled (" config" ) then
Original file line number Diff line number Diff line change @@ -532,6 +532,19 @@ local function process_config(g)
532532 end
533533end
534534
535+ --- Hijack and disable netrw if (globally) configured
536+ --- @param g nvim_tree.config
537+ local function manage_netrw (g )
538+ if g .hijack_netrw then
539+ vim .cmd (" silent! autocmd! FileExplorer *" )
540+ vim .cmd (" autocmd VimEnter * ++once silent! autocmd! FileExplorer *" )
541+ end
542+ if g .disable_netrw then
543+ vim .g .loaded_netrw = 1
544+ vim .g .loaded_netrwPlugin = 1
545+ end
546+ end
547+
535548--- Validate user config and migrate legacy.
536549--- Merge with M.d and persist as M.g
537550--- When no user config M.g is set to M.d and M.u is set to nil
@@ -559,6 +572,9 @@ function M.setup(u)
559572 -- process merged config
560573 process_config (M .g )
561574
575+ -- deal with netrw
576+ manage_netrw (M .g )
577+
562578 -- store cwd
563579 M .init_root = vim .fn .getcwd ()
564580end
You can’t perform that action at this time.
0 commit comments