chore: move g:nvim_tree_quit_on_open into open_file action config

This commit is contained in:
kiyan
2022-02-05 18:42:08 +01:00
parent 756b7acc52
commit 1fe29f8eef
7 changed files with 35 additions and 40 deletions

View File

@@ -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

View File

@@ -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)

View File

@@ -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