chore: update_to_buf_dir allow auto_open configuration
also improve the documentation with doc references
This commit is contained in:
parent
4cfe355035
commit
137628acb6
@ -50,7 +50,12 @@ require'nvim-tree'.setup {
|
||||
-- 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,
|
||||
update_to_buf_dir = {
|
||||
-- enable the feature
|
||||
enable = true,
|
||||
-- allow to open the tree if it was previously closed
|
||||
auto_open = 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)
|
||||
|
||||
@ -59,7 +59,7 @@ Resize the NvimTree window to the given size. Example: `:NvimTreeresize 50`
|
||||
resizes the window to the width of 50.
|
||||
|
||||
==============================================================================
|
||||
SETUP *nvim-tree-setup*
|
||||
SETUP *nvim-tree.setup*
|
||||
|
||||
To configure the tree (and make it runnable), you should call the setup
|
||||
function.
|
||||
@ -70,7 +70,10 @@ function.
|
||||
hijack_netrw = true,
|
||||
open_on_setup = false,
|
||||
ignore_ft_on_setup = {},
|
||||
update_to_buf_dir = true,
|
||||
update_to_buf_dir = {
|
||||
enable = true,
|
||||
auto_open = true,
|
||||
},
|
||||
auto_close = false,
|
||||
open_on_tab = false,
|
||||
hijack_cursor = false,
|
||||
@ -101,51 +104,65 @@ As options are currently being migrated, configuration of global options in
|
||||
|nvim-tree-options| should be done BEFORE the setup call.
|
||||
|
||||
Here is a list of the options available in the setup call:
|
||||
|
||||
*nvim-tree.disable_netrw*
|
||||
- |disable_netrw|: completely disable netrw
|
||||
type: `boolean`
|
||||
default: `true`
|
||||
|
||||
*nvim-tree.hijack_netrw*
|
||||
- |hijack_netrw|: hijack netrw windows (overriden if |disable_netrw| is `true`)
|
||||
type: `boolean`
|
||||
default: `true`
|
||||
|
||||
*nvim-tree.open_on_setup*
|
||||
- |open_on_setup|: will automatically open the tree when running setup if current
|
||||
buffer is a directory, is empty or is unnamed.
|
||||
type: `boolean`
|
||||
default: `false`
|
||||
|
||||
*nvim-tree.ignore_ft_on_setup*
|
||||
- |ignore_ft_on_setup|: list of filetypes that will make |open_on_setup| not
|
||||
open. You can use this option if you don't want the tree to open in some
|
||||
scenarios (eg using vim startify).
|
||||
type: `{string}`
|
||||
default: `{}`
|
||||
|
||||
*nvim-tree.auto_close*
|
||||
- |auto_close|: force closing neovim when the tree is the last window in the view.
|
||||
type: `boolean`
|
||||
default: `false`
|
||||
|
||||
*nvim-tree.open_on_tab*
|
||||
- |open_on_tab|: opens the tree automatically when switching tabpage or opening a new
|
||||
tabpage if the tree was previously open.
|
||||
type: `boolean`
|
||||
default: `false`
|
||||
|
||||
*nvim-tree.update_to_buf_dir*
|
||||
- |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.
|
||||
|
||||
- |update_to_buf_dir.enable|: enable the feature. Disable this option if you use vim-dirvish.
|
||||
type: `boolean`
|
||||
default: `true`
|
||||
|
||||
- |update_to_buf_dir.auto_open|: opens the tree if the tree was previously closed.
|
||||
type: `boolean`
|
||||
default: `true`
|
||||
|
||||
*nvim-tree.hijack_cursor*
|
||||
- |hijack_cursor|: keeps the cursor on the first letter of the filename when
|
||||
moving in the tree.
|
||||
type: `boolean`
|
||||
default: `false`
|
||||
|
||||
*nvim-tree.update_cwd*
|
||||
- |update_cwd|: changes the tree root directory on `DirChanged` and refreshes
|
||||
the tree.
|
||||
type: `boolean`
|
||||
default: `false`
|
||||
|
||||
*nvim-tree.update_focused_file*
|
||||
- |update_focused_file|: update the focused file on `BufEnter`, un-collapses
|
||||
the folders recursively until it finds the file
|
||||
|
||||
@ -166,6 +183,7 @@ Here is a list of the options available in the setup call:
|
||||
type: `{string}`
|
||||
default: `{}`
|
||||
|
||||
*nvim-tree.system_open*
|
||||
- |system_open|: configuration options for the system open command
|
||||
|
||||
- |system_open.cmd|: the command to run, leaving nil should work but
|
||||
@ -177,10 +195,12 @@ Here is a list of the options available in the setup call:
|
||||
type: `{string}`
|
||||
default: `{}`
|
||||
|
||||
*nvim-tree.lsp_diagnostics*
|
||||
- |lsp_diagnostics|: show lsp diagnostics in the signcolumn
|
||||
type: `boolean`
|
||||
default: false
|
||||
|
||||
*nvim-tree.view*
|
||||
- |view|: window / buffer setup
|
||||
|
||||
- |view.width|: width of the window, can be either a `%` string or
|
||||
|
||||
@ -12,15 +12,6 @@ local _config = {
|
||||
is_windows = vim.fn.has('win32') == 1 or vim.fn.has('win32unix') == 1,
|
||||
is_macos = vim.fn.has('mac') == 1 or vim.fn.has('macunix') == 1,
|
||||
is_unix = vim.fn.has('unix') == 1,
|
||||
update_focused_file = {
|
||||
enable = false,
|
||||
update_cwd = false,
|
||||
ignore_list = {},
|
||||
},
|
||||
system_open = {},
|
||||
ignore_ft_on_setup = {},
|
||||
open_on_setup = false,
|
||||
update_to_buf_dir = true,
|
||||
}
|
||||
|
||||
local M = {}
|
||||
@ -302,7 +293,8 @@ function M.on_leave()
|
||||
end
|
||||
|
||||
function M.open_on_directory()
|
||||
if not (_config.update_to_buf_dir and (_config.open_on_setup or view.win_open())) then
|
||||
local should_proceed = _config.update_to_buf_dir.auto_open or view.win_open()
|
||||
if not _config.update_to_buf_dir.enable or not should_proceed then
|
||||
return
|
||||
end
|
||||
local buf = api.nvim_get_current_buf()
|
||||
@ -408,7 +400,10 @@ local DEFAULT_OPTS = {
|
||||
hijack_netrw = true,
|
||||
open_on_setup = false,
|
||||
open_on_tab = false,
|
||||
update_to_buf_dir = true,
|
||||
update_to_buf_dir = {
|
||||
enable = true,
|
||||
auto_open = true,
|
||||
},
|
||||
auto_close = false,
|
||||
hijack_cursor = false,
|
||||
update_cwd = false,
|
||||
@ -434,7 +429,15 @@ 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
|
||||
if type(opts.update_to_buf_dir) == "boolean" then
|
||||
require'nvim-tree.utils'.echo_warning("update_to_buf_dir is now a table, see :help nvim-tree.update_to_buf_dir")
|
||||
_config.update_to_buf_dir = {
|
||||
enable = opts.update_to_buf_dir,
|
||||
auto_open = opts.update_to_buf_dir,
|
||||
}
|
||||
else
|
||||
_config.update_to_buf_dir = opts.update_to_buf_dir
|
||||
end
|
||||
|
||||
require'nvim-tree.colors'.setup()
|
||||
require'nvim-tree.view'.setup(opts.view or {})
|
||||
|
||||
Loading…
Reference in New Issue
Block a user