feat: focus_empty_on_setup
This commit is contained in:
parent
540055be5f
commit
0417d9148b
@ -175,6 +175,7 @@ Subsequent calls to setup will replace the previous configuration.
|
|||||||
open_on_setup = false,
|
open_on_setup = false,
|
||||||
open_on_setup_file = false,
|
open_on_setup_file = false,
|
||||||
open_on_tab = false,
|
open_on_tab = false,
|
||||||
|
focus_empty_on_setup = false,
|
||||||
ignore_buf_on_tab_change = {},
|
ignore_buf_on_tab_change = {},
|
||||||
sort_by = "name",
|
sort_by = "name",
|
||||||
root_dirs = {},
|
root_dirs = {},
|
||||||
@ -391,6 +392,7 @@ Hijack netrw windows (overridden if |disable_netrw| is `true`)
|
|||||||
*nvim-tree.open_on_setup*
|
*nvim-tree.open_on_setup*
|
||||||
Will automatically open the tree when running setup if startup buffer is
|
Will automatically open the tree when running setup if startup buffer is
|
||||||
a directory, is empty or is unnamed. nvim-tree window will be focused.
|
a directory, is empty or is unnamed. nvim-tree window will be focused.
|
||||||
|
See |nvim-tree.focus_empty_on_setup|
|
||||||
Type: `boolean`, Default: `false`
|
Type: `boolean`, Default: `false`
|
||||||
|
|
||||||
*nvim-tree.open_on_setup_file*
|
*nvim-tree.open_on_setup_file*
|
||||||
@ -427,6 +429,11 @@ Opens the tree automatically when switching tabpage or opening a new tabpage
|
|||||||
if the tree was previously open.
|
if the tree was previously open.
|
||||||
Type: `boolean`, Default: `false`
|
Type: `boolean`, Default: `false`
|
||||||
|
|
||||||
|
*nvim-tree.focus_empty_on_setup*
|
||||||
|
When the tree opens as a result of |nvim-tree.open_on_setup| or
|
||||||
|
|nvim-tree.open_on_tab| and the buffer is empty, focus the buffer.
|
||||||
|
Type: `boolean`, Default: `false`
|
||||||
|
|
||||||
*nvim-tree.sort_by*
|
*nvim-tree.sort_by*
|
||||||
Changes how files within the same directory are sorted.
|
Changes how files within the same directory are sorted.
|
||||||
Can be one of `name`, `case_sensitive`, `modification_time`, `extension` or a
|
Can be one of `name`, `case_sensitive`, `modification_time`, `extension` or a
|
||||||
|
|||||||
@ -244,7 +244,10 @@ function M.on_enter(netrw_disabled)
|
|||||||
local should_focus_other_window = false
|
local should_focus_other_window = false
|
||||||
local should_find = false
|
local should_find = false
|
||||||
if (_config.open_on_setup or _config.open_on_setup_file) and not should_be_preserved then
|
if (_config.open_on_setup or _config.open_on_setup_file) and not should_be_preserved then
|
||||||
if buf_is_dir or buf_is_empty then
|
if buf_is_empty then
|
||||||
|
should_open = true
|
||||||
|
should_focus_other_window = _config.focus_empty_on_setup
|
||||||
|
elseif buf_is_dir then
|
||||||
should_open = true
|
should_open = true
|
||||||
elseif is_file and _config.open_on_setup_file then
|
elseif is_file and _config.open_on_setup_file then
|
||||||
should_open = true
|
should_open = true
|
||||||
@ -431,6 +434,7 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
|
|||||||
open_on_setup = false,
|
open_on_setup = false,
|
||||||
open_on_setup_file = false,
|
open_on_setup_file = false,
|
||||||
open_on_tab = false,
|
open_on_tab = false,
|
||||||
|
focus_empty_on_setup = false,
|
||||||
ignore_buf_on_tab_change = {},
|
ignore_buf_on_tab_change = {},
|
||||||
sort_by = "name",
|
sort_by = "name",
|
||||||
root_dirs = {},
|
root_dirs = {},
|
||||||
@ -704,6 +708,7 @@ function M.setup(conf)
|
|||||||
_config.update_focused_file = opts.update_focused_file
|
_config.update_focused_file = opts.update_focused_file
|
||||||
_config.open_on_setup = opts.open_on_setup
|
_config.open_on_setup = opts.open_on_setup
|
||||||
_config.open_on_setup_file = opts.open_on_setup_file
|
_config.open_on_setup_file = opts.open_on_setup_file
|
||||||
|
_config.focus_empty_on_setup = opts.focus_empty_on_setup
|
||||||
_config.ignore_buffer_on_setup = opts.ignore_buffer_on_setup
|
_config.ignore_buffer_on_setup = opts.ignore_buffer_on_setup
|
||||||
_config.ignore_ft_on_setup = opts.ignore_ft_on_setup
|
_config.ignore_ft_on_setup = opts.ignore_ft_on_setup
|
||||||
_config.ignore_buf_on_tab_change = opts.ignore_buf_on_tab_change
|
_config.ignore_buf_on_tab_change = opts.ignore_buf_on_tab_change
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user