chore: remove auto close
also fix emmylua errors in log.lua file fixes #1005 fixes #871
This commit is contained in:
@@ -117,7 +117,6 @@ require'nvim-tree'.setup {
|
|||||||
-- setup with all defaults
|
-- setup with all defaults
|
||||||
-- each of these are documented in `:help nvim-tree.OPTION_NAME`
|
-- each of these are documented in `:help nvim-tree.OPTION_NAME`
|
||||||
require'nvim-tree'.setup { -- BEGIN_DEFAULT_OPTS
|
require'nvim-tree'.setup { -- BEGIN_DEFAULT_OPTS
|
||||||
auto_close = false,
|
|
||||||
auto_reload_on_write = true,
|
auto_reload_on_write = true,
|
||||||
disable_netrw = false,
|
disable_netrw = false,
|
||||||
hide_root_folder = false,
|
hide_root_folder = false,
|
||||||
@@ -331,6 +330,10 @@ You can toggle the help UI by pressing `g?`.
|
|||||||
3. `toggle` has a second parameter which allows to toggle without focusing the explorer (`require"nvim-tree.toggle(false, false)`).
|
3. `toggle` has a second parameter which allows to toggle without focusing the explorer (`require"nvim-tree.toggle(false, false)`).
|
||||||
4. You can allow nvim-tree to behave like vinegar (see `:help nvim-tree-vinegar`).
|
4. You can allow nvim-tree to behave like vinegar (see `:help nvim-tree-vinegar`).
|
||||||
5. If you `:set nosplitright`, the files will open on the left side of the tree, placing the tree window in the right side of the file you opened.
|
5. If you `:set nosplitright`, the files will open on the left side of the tree, placing the tree window in the right side of the file you opened.
|
||||||
|
6. You can automatically close the tab/vim when nvim-tree is the last window in the tab. WARNING: other plugins or automation may interfere with this:
|
||||||
|
```vim
|
||||||
|
autocmd BufEnter * ++nested if winnr('$') == 1 && bufname() == 'NvimTree_' . tabpagenr() | quit | endif
|
||||||
|
```
|
||||||
|
|
||||||
## Diagnostic Logging
|
## Diagnostic Logging
|
||||||
|
|
||||||
|
|||||||
@@ -84,7 +84,6 @@ function.
|
|||||||
|
|
||||||
>
|
>
|
||||||
require("nvim-tree").setup { -- BEGIN_DEFAULT_OPTS
|
require("nvim-tree").setup { -- BEGIN_DEFAULT_OPTS
|
||||||
auto_close = false,
|
|
||||||
auto_reload_on_write = true,
|
auto_reload_on_write = true,
|
||||||
disable_netrw = false,
|
disable_netrw = false,
|
||||||
hide_root_folder = false,
|
hide_root_folder = false,
|
||||||
@@ -215,11 +214,6 @@ Here is a list of the options available in the setup call:
|
|||||||
type: `{string}`
|
type: `{string}`
|
||||||
default: `{}`
|
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.auto_reload_on_write*
|
*nvim-tree.auto_reload_on_write*
|
||||||
- |auto_reload_on_write|: reloads the explorer every time a buffer is written to
|
- |auto_reload_on_write|: reloads the explorer every time a buffer is written to
|
||||||
type: `boolean`
|
type: `boolean`
|
||||||
|
|||||||
@@ -131,38 +131,6 @@ end
|
|||||||
|
|
||||||
M.resize = view.resize
|
M.resize = view.resize
|
||||||
|
|
||||||
local function should_abort_auto_close()
|
|
||||||
local buf = api.nvim_get_current_buf()
|
|
||||||
local buftype = api.nvim_buf_get_option(buf, "ft")
|
|
||||||
local modified = vim.tbl_filter(function(b)
|
|
||||||
return api.nvim_buf_get_option(b, "modified")
|
|
||||||
end, api.nvim_list_bufs())
|
|
||||||
return #modified > 0 or buftype:match "Telescope" ~= nil
|
|
||||||
end
|
|
||||||
|
|
||||||
function M.auto_close()
|
|
||||||
if should_abort_auto_close() then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
vim.defer_fn(function()
|
|
||||||
if not view.is_visible() then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local windows = api.nvim_list_wins()
|
|
||||||
local curtab = api.nvim_get_current_tabpage()
|
|
||||||
local wins_in_tabpage = vim.tbl_filter(function(w)
|
|
||||||
return api.nvim_win_get_tabpage(w) == curtab
|
|
||||||
end, windows)
|
|
||||||
if #windows == 1 then
|
|
||||||
api.nvim_command ":silent qa!"
|
|
||||||
elseif #wins_in_tabpage == 1 then
|
|
||||||
api.nvim_command ":tabclose"
|
|
||||||
end
|
|
||||||
end, 50)
|
|
||||||
end
|
|
||||||
|
|
||||||
function M.open_on_directory()
|
function M.open_on_directory()
|
||||||
local should_proceed = M.initialized and (_config.hijack_directories.auto_open or view.is_visible())
|
local should_proceed = M.initialized and (_config.hijack_directories.auto_open or view.is_visible())
|
||||||
if not should_proceed then
|
if not should_proceed then
|
||||||
@@ -305,9 +273,6 @@ local function setup_autocommands(opts)
|
|||||||
end
|
end
|
||||||
vim.cmd "au User FugitiveChanged,NeogitStatusRefreshed lua require'nvim-tree.actions.reloaders'.reload_git()"
|
vim.cmd "au User FugitiveChanged,NeogitStatusRefreshed lua require'nvim-tree.actions.reloaders'.reload_git()"
|
||||||
|
|
||||||
if opts.auto_close then
|
|
||||||
vim.cmd "au WinClosed * lua require'nvim-tree'.auto_close()"
|
|
||||||
end
|
|
||||||
if opts.open_on_tab then
|
if opts.open_on_tab then
|
||||||
vim.cmd "au TabEnter * lua require'nvim-tree'.tab_change()"
|
vim.cmd "au TabEnter * lua require'nvim-tree'.tab_change()"
|
||||||
end
|
end
|
||||||
@@ -335,7 +300,6 @@ local function setup_autocommands(opts)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
|
local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
|
||||||
auto_close = false,
|
|
||||||
auto_reload_on_write = true,
|
auto_reload_on_write = true,
|
||||||
disable_netrw = false,
|
disable_netrw = false,
|
||||||
hide_root_folder = false,
|
hide_root_folder = false,
|
||||||
@@ -445,6 +409,10 @@ function M.setup(conf)
|
|||||||
local opts = merge_options(conf)
|
local opts = merge_options(conf)
|
||||||
local netrw_disabled = opts.disable_netrw or opts.hijack_netrw
|
local netrw_disabled = opts.disable_netrw or opts.hijack_netrw
|
||||||
|
|
||||||
|
if opts.auto_close then
|
||||||
|
utils.warn "auto close feature has been removed, see note in the README (tips & reminder section)"
|
||||||
|
end
|
||||||
|
|
||||||
_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.ignore_buffer_on_setup = opts.ignore_buffer_on_setup
|
_config.ignore_buffer_on_setup = opts.ignore_buffer_on_setup
|
||||||
|
|||||||
@@ -24,12 +24,6 @@ local migrations = {
|
|||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
nvim_tree_auto_close = function(o)
|
|
||||||
if o.auto_close == nil then
|
|
||||||
o.auto_close = vim.g.nvim_tree_auto_close ~= 0
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
|
|
||||||
nvim_tree_tab_open = function(o)
|
nvim_tree_tab_open = function(o)
|
||||||
if o.open_on_tab == nil then
|
if o.open_on_tab == nil then
|
||||||
o.open_on_tab = vim.g.nvim_tree_tab_open ~= 0
|
o.open_on_tab = vim.g.nvim_tree_tab_open ~= 0
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ local M = {
|
|||||||
--- Write to log file
|
--- Write to log file
|
||||||
--- @param typ string as per log.types config
|
--- @param typ string as per log.types config
|
||||||
--- @param fmt string for string.format
|
--- @param fmt string for string.format
|
||||||
--- @param ... any arguments for string.format
|
--- @vararg any arguments for string.format
|
||||||
function M.raw(typ, fmt, ...)
|
function M.raw(typ, fmt, ...)
|
||||||
if not M.path or not M.config.types[typ] and not M.config.types.all then
|
if not M.path or not M.config.types[typ] and not M.config.types.all then
|
||||||
return
|
return
|
||||||
@@ -23,7 +23,7 @@ end
|
|||||||
|
|
||||||
--- Write to log file via M.line
|
--- Write to log file via M.line
|
||||||
--- START is prefixed
|
--- START is prefixed
|
||||||
--- @return nanos to pass to profile_end
|
--- @return number nanos to pass to profile_end
|
||||||
function M.profile_start(fmt, ...)
|
function M.profile_start(fmt, ...)
|
||||||
if not M.path or not M.config.types.profile and not M.config.types.all then
|
if not M.path or not M.config.types.profile and not M.config.types.all then
|
||||||
return
|
return
|
||||||
@@ -34,7 +34,7 @@ end
|
|||||||
|
|
||||||
--- Write to log file via M.line
|
--- Write to log file via M.line
|
||||||
--- END is prefixed and duration in seconds is suffixed
|
--- END is prefixed and duration in seconds is suffixed
|
||||||
--- @param start nanos returned from profile_start
|
--- @param start number nanos returned from profile_start
|
||||||
function M.profile_end(start, fmt, ...)
|
function M.profile_end(start, fmt, ...)
|
||||||
if not M.path or not M.config.types.profile and not M.config.types.all then
|
if not M.path or not M.config.types.profile and not M.config.types.all then
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user