chore: move g:nvim_tree_quit_on_open into open_file action config
This commit is contained in:
@@ -27,11 +27,7 @@ function M.fn(name)
|
||||
end
|
||||
|
||||
function M.setup(options)
|
||||
if options.actions.change_dir.global ~= nil then
|
||||
M.options.global = options.actions.change_dir.global
|
||||
else
|
||||
M.options.global = vim.g.nvim_tree_change_dir_global == 1
|
||||
end
|
||||
M.options.global = options.actions.change_dir.global
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
@@ -169,6 +169,7 @@ local DEFAULT_MAPPING_CONFIG = {
|
||||
function M.setup(opts)
|
||||
require'nvim-tree.actions.system-open'.setup(opts.system_open)
|
||||
require'nvim-tree.actions.trash'.setup(opts.trash)
|
||||
require'nvim-tree.actions.open-file'.setup(opts)
|
||||
|
||||
local user_map_config = (opts.view or {}).mappings or {}
|
||||
local options = vim.tbl_deep_extend('force', DEFAULT_MAPPING_CONFIG, user_map_config)
|
||||
|
||||
@@ -5,7 +5,9 @@ local lib = require'nvim-tree.lib'
|
||||
local utils = require'nvim-tree.utils'
|
||||
local view = require'nvim-tree.view'
|
||||
|
||||
local M = {}
|
||||
local M = {
|
||||
quit_on_open = false,
|
||||
}
|
||||
|
||||
---Get user to pick a window. Selectable windows are all windows in the current
|
||||
---tabpage that aren't NvimTree.
|
||||
@@ -88,8 +90,7 @@ local function pick_window()
|
||||
end
|
||||
|
||||
local function open_file_in_tab(filename)
|
||||
local close = vim.g.nvim_tree_quit_on_open == 1
|
||||
if close then
|
||||
if M.quit_on_open then
|
||||
view.close()
|
||||
else
|
||||
-- Switch window first to ensure new window doesn't inherit settings from
|
||||
@@ -114,7 +115,7 @@ local function open_file_in_tab(filename)
|
||||
api.nvim_set_current_buf(alt_bufid)
|
||||
end
|
||||
|
||||
if not close then
|
||||
if not M.quit_on_open then
|
||||
vim.cmd("wincmd p")
|
||||
end
|
||||
|
||||
@@ -194,9 +195,13 @@ function M.fn(mode, filename)
|
||||
return
|
||||
end
|
||||
|
||||
if vim.g.nvim_tree_quit_on_open == 1 then
|
||||
if M.quit_on_open then
|
||||
view.close()
|
||||
end
|
||||
end
|
||||
|
||||
function M.setup(opts)
|
||||
M.quit_on_open = opts.actions.open_file.quit_on_open
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
@@ -72,19 +72,21 @@ local DEFAULT_CONFIG = {
|
||||
}
|
||||
|
||||
function M.setup(opts)
|
||||
local options = vim.tbl_deep_extend('force', DEFAULT_CONFIG, opts)
|
||||
local options = vim.tbl_deep_extend('force', DEFAULT_CONFIG, opts.view or {})
|
||||
M.View.side = options.side
|
||||
M.View.width = options.width
|
||||
M.View.height = options.height
|
||||
M.View.hide_root_folder = options.hide_root_folder
|
||||
M.View.auto_resize = opts.auto_resize
|
||||
M.View.auto_resize = options.auto_resize
|
||||
M.View.winopts.number = options.number
|
||||
M.View.winopts.relativenumber = options.relativenumber
|
||||
M.View.winopts.signcolumn = options.signcolumn
|
||||
|
||||
vim.cmd "augroup NvimTreeView"
|
||||
vim.cmd "au!"
|
||||
vim.cmd "au BufWinEnter,BufWinLeave * lua require'nvim-tree.view'._prevent_buffer_override()"
|
||||
if not opts.actions.open_file.quit_on_open then
|
||||
vim.cmd "au BufWinEnter,BufWinLeave * lua require'nvim-tree.view'._prevent_buffer_override()"
|
||||
end
|
||||
vim.cmd "au BufEnter,BufNewFile * lua require'nvim-tree'.open_on_directory()"
|
||||
vim.cmd "augroup END"
|
||||
|
||||
@@ -127,9 +129,6 @@ function M._prevent_buffer_override()
|
||||
end
|
||||
vim.cmd("buffer "..curbuf)
|
||||
M.resize()
|
||||
if vim.g.nvim_tree_quit_on_open == 1 then
|
||||
M.close()
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user