fix(temporary): defer colors setup and hijack window
lazy loading + opening will close the window. Need to find a fix for this. fixes #947
This commit is contained in:
@@ -107,6 +107,8 @@ function M.on_enter(netrw_disabled)
|
|||||||
local cwd
|
local cwd
|
||||||
if is_dir then
|
if is_dir then
|
||||||
cwd = vim.fn.expand(bufname)
|
cwd = vim.fn.expand(bufname)
|
||||||
|
-- INFO: could potentially conflict with rooter plugins
|
||||||
|
vim.cmd("noautocmd cd "..cwd)
|
||||||
end
|
end
|
||||||
|
|
||||||
local lines = not is_dir and api.nvim_buf_get_lines(bufnr, 0, -1, false) or {}
|
local lines = not is_dir and api.nvim_buf_get_lines(bufnr, 0, -1, false) or {}
|
||||||
@@ -116,17 +118,13 @@ function M.on_enter(netrw_disabled)
|
|||||||
local buf_is_empty = bufname == "" and not buf_has_content
|
local buf_is_empty = bufname == "" and not buf_has_content
|
||||||
local should_be_preserved = vim.tbl_contains(ft_ignore, buftype)
|
local should_be_preserved = vim.tbl_contains(ft_ignore, buftype)
|
||||||
local should_open = _config.open_on_setup and not should_be_preserved and (buf_is_dir or buf_is_empty)
|
local should_open = _config.open_on_setup and not should_be_preserved and (buf_is_dir or buf_is_empty)
|
||||||
|
local should_hijack = _config.update_to_buf_dir.enable and _config.update_to_buf_dir.auto_open and is_dir and not should_be_preserved
|
||||||
|
|
||||||
if should_open then
|
if should_hijack or should_open then
|
||||||
M.hijack_current_window()
|
M.hijack_current_window()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- INFO: could potentially conflict with rooter plugins
|
lib.init(should_open or should_hijack, cwd)
|
||||||
if cwd and should_open then
|
|
||||||
vim.cmd("noautocmd cd "..cwd)
|
|
||||||
end
|
|
||||||
|
|
||||||
lib.init(should_open, cwd)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function is_file_readable(fname)
|
local function is_file_readable(fname)
|
||||||
@@ -375,7 +373,6 @@ function M.setup(conf)
|
|||||||
_config.update_to_buf_dir = opts.update_to_buf_dir
|
_config.update_to_buf_dir = opts.update_to_buf_dir
|
||||||
_config.update_to_buf_dir.enable = _config.update_to_buf_dir.enable and netrw_disabled
|
_config.update_to_buf_dir.enable = _config.update_to_buf_dir.enable and netrw_disabled
|
||||||
|
|
||||||
require'nvim-tree.colors'.setup()
|
|
||||||
require'nvim-tree.actions'.setup(opts)
|
require'nvim-tree.actions'.setup(opts)
|
||||||
require'nvim-tree.diagnostics'.setup(opts)
|
require'nvim-tree.diagnostics'.setup(opts)
|
||||||
require'nvim-tree.explorer'.setup(opts)
|
require'nvim-tree.explorer'.setup(opts)
|
||||||
@@ -384,6 +381,7 @@ function M.setup(conf)
|
|||||||
setup_vim_commands()
|
setup_vim_commands()
|
||||||
|
|
||||||
vim.schedule(function()
|
vim.schedule(function()
|
||||||
|
require'nvim-tree.colors'.setup()
|
||||||
require'nvim-tree.view'.create_buffer()
|
require'nvim-tree.view'.create_buffer()
|
||||||
M.on_enter(netrw_disabled)
|
M.on_enter(netrw_disabled)
|
||||||
setup_autocommands(opts)
|
setup_autocommands(opts)
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ local function wipe_rogue_buffer()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- FIXME: setting options to buffer clears the startup screen
|
||||||
function M.create_buffer()
|
function M.create_buffer()
|
||||||
wipe_rogue_buffer()
|
wipe_rogue_buffer()
|
||||||
M.View.bufnr = a.nvim_create_buf(false, false)
|
M.View.bufnr = a.nvim_create_buf(false, false)
|
||||||
|
|||||||
Reference in New Issue
Block a user