fix: add option update_to_buf_dir in setup

avoid hijacking the tree for use case of users using vim-dirvish
This commit is contained in:
kiyan 2021-09-30 12:43:20 +02:00
parent e2e7720caa
commit 9282944078
3 changed files with 14 additions and 1 deletions

View File

@ -47,6 +47,8 @@ require'nvim-tree'.setup {
auto_close = false,
-- opens the tree when changing/opening a new tab if the tree wasn't previously opened
open_on_tab = false,
-- hijacks new directory buffers when they are opened.
update_to_buf_dir = true,
-- hijack the cursor in the tree to put it at the start of the filename
hijack_cursor = false,
-- updates the root directory of the tree on `DirChanged` (when your run `:cd` usually)

View File

@ -70,6 +70,7 @@ function.
hijack_netrw = true,
open_on_setup = false,
ignore_ft_on_setup = {},
update_to_buf_dir = true,
auto_close = false,
open_on_tab = false,
hijack_cursor = false,
@ -128,6 +129,13 @@ Here is a list of the options available in the setup call:
type: `boolean`
default: `false`
- |update_to_buf_dir|: hijacks new directory buffers when they are opened (`:e dir`).
If |open_on_setup| is enabled, it will open the tree if the tree is closed.
Disable this option if you use vim-dirvish.
type: `boolean`
default: `true`
- |hijack_cursor|: keeps the cursor on the first letter of the filename when
moving in the tree.
type: `boolean`

View File

@ -20,6 +20,7 @@ local _config = {
system_open = {},
ignore_ft_on_setup = {},
open_on_setup = false,
update_to_buf_dir = true,
}
local M = {}
@ -301,7 +302,7 @@ function M.on_leave()
end
function M.open_on_directory()
if not (_config.open_on_setup or view.win_open()) then
if not (_config.update_to_buf_dir and (_config.open_on_setup or view.win_open())) then
return
end
local buf = api.nvim_get_current_buf()
@ -405,6 +406,7 @@ local DEFAULT_OPTS = {
hijack_netrw = true,
open_on_setup = false,
open_on_tab = false,
update_to_buf_dir = true,
auto_close = false,
hijack_cursor = false,
update_cwd = false,
@ -430,6 +432,7 @@ function M.setup(conf)
_config.system_open = opts.system_open
_config.open_on_setup = opts.open_on_setup
_config.ignore_ft_on_setup = opts.ignore_ft_on_setup
_config.update_to_buf_dir = opts.update_to_buf_dir
require'nvim-tree.colors'.setup()
require'nvim-tree.view'.setup(opts.view or {})