Give users the option to enable netrw
This commit is contained in:
parent
5b428c014a
commit
aab0a136ac
@ -32,6 +32,8 @@ let g:nvim_tree_git_hl = 1 "0 by default, will enable file highlight for git att
|
||||
let g:nvim_tree_root_folder_modifier = ':~' "This is the default. See :help filename-modifiers for more options
|
||||
let g:nvim_tree_tab_open = 1 "0 by default, will open the tree when entering a new tab and the tree was previously open
|
||||
let g:nvim_tree_width_allow_resize = 1 "0 by default, will not resize the tree when opening a file
|
||||
let g:nvim_tree_disable_netrw = 0 "1 by default, disables netrw
|
||||
let g:nvim_tree_hijack_netrw = 0 "1 by default, prevents netrw from automatically opening when opening directories (but lets you keep its other utilities)
|
||||
let g:nvim_tree_show_icons = {
|
||||
\ 'git': 1,
|
||||
\ 'folders': 0,
|
||||
|
||||
@ -124,11 +124,14 @@ function M.on_enter()
|
||||
|
||||
local stats = luv.fs_stat(bufname)
|
||||
local is_dir = stats and stats.type == 'directory'
|
||||
|
||||
local disable_netrw = vim.g.nvim_tree_disable_netrw or 1
|
||||
local hijack_netrw = vim.g.nvim_tree_hijack_netrw or 1
|
||||
if is_dir then
|
||||
api.nvim_command('cd '..bufname)
|
||||
end
|
||||
local should_open = vim.g.nvim_tree_auto_open == 1 and
|
||||
(bufname == '' or is_dir) and
|
||||
((is_dir and (hijack_netrw == 1 or disable_netrw == 1)) or bufname == '') and
|
||||
not vim.tbl_contains(ft_ignore, buftype)
|
||||
colors.setup()
|
||||
lib.init(should_open, should_open)
|
||||
|
||||
@ -3,12 +3,17 @@ if has('win32') || exists('g:loaded_tree') | finish | endif
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
let g:loaded_netrw = 1
|
||||
let g:loaded_netrwPlugin = 1
|
||||
if get(g:, 'nvim_tree_disable_netrw', 1) == 1
|
||||
let g:loaded_netrw = 1
|
||||
let g:loaded_netrwPlugin = 1
|
||||
endif
|
||||
|
||||
hi def link NvimTreePopup Normal
|
||||
|
||||
augroup NvimTree
|
||||
if get(g:, 'nvim_tree_hijack_netrw', 1) == 1 && get(g:, 'nvim_tree_disable_netrw', 1) == 0
|
||||
autocmd! FileExplorer *
|
||||
endif
|
||||
au BufWritePost * lua require'nvim-tree'.refresh()
|
||||
au BufEnter * lua require'nvim-tree'.buf_enter()
|
||||
if get(g:, 'nvim_tree_auto_close') == 1
|
||||
|
||||
Loading…
Reference in New Issue
Block a user