fix: create buffer during setup schedule
and move view setup before setup schedule Fixes #951
This commit is contained in:
@@ -380,10 +380,11 @@ function M.setup(conf)
|
|||||||
require'nvim-tree.diagnostics'.setup(opts)
|
require'nvim-tree.diagnostics'.setup(opts)
|
||||||
require'nvim-tree.explorer'.setup(opts)
|
require'nvim-tree.explorer'.setup(opts)
|
||||||
require'nvim-tree.git'.setup(opts)
|
require'nvim-tree.git'.setup(opts)
|
||||||
|
require'nvim-tree.view'.setup(opts)
|
||||||
setup_vim_commands()
|
setup_vim_commands()
|
||||||
|
|
||||||
vim.schedule(function()
|
vim.schedule(function()
|
||||||
require'nvim-tree.view'.setup(opts)
|
require'nvim-tree.view'.create_buffer()
|
||||||
M.on_enter(netrw_disabled)
|
M.on_enter(netrw_disabled)
|
||||||
setup_autocommands(opts)
|
setup_autocommands(opts)
|
||||||
end)
|
end)
|
||||||
|
|||||||
@@ -371,7 +371,9 @@ end
|
|||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
function M.draw()
|
function M.draw()
|
||||||
if not api.nvim_buf_is_loaded(view.View.bufnr) then return end
|
if not TreeExplorer or not api.nvim_buf_is_loaded(view.View.bufnr) then
|
||||||
|
return
|
||||||
|
end
|
||||||
local cursor
|
local cursor
|
||||||
if view.win_open() then
|
if view.win_open() then
|
||||||
cursor = api.nvim_win_get_cursor(view.get_winnr())
|
cursor = api.nvim_win_get_cursor(view.get_winnr())
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ local function wipe_rogue_buffer()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function 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)
|
||||||
a.nvim_buf_set_name(M.View.bufnr, 'NvimTree')
|
a.nvim_buf_set_name(M.View.bufnr, 'NvimTree')
|
||||||
@@ -82,7 +82,6 @@ function M.setup(opts)
|
|||||||
M.View.winopts.number = options.number
|
M.View.winopts.number = options.number
|
||||||
M.View.winopts.relativenumber = options.relativenumber
|
M.View.winopts.relativenumber = options.relativenumber
|
||||||
M.View.winopts.signcolumn = options.signcolumn
|
M.View.winopts.signcolumn = options.signcolumn
|
||||||
create_buffer()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local move_cmd = {
|
local move_cmd = {
|
||||||
@@ -222,7 +221,7 @@ local function open_window()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function is_buf_valid(bufnr)
|
local function is_buf_valid(bufnr)
|
||||||
return a.nvim_buf_is_valid(bufnr) and a.nvim_buf_is_loaded(bufnr)
|
return bufnr and a.nvim_buf_is_valid(bufnr) and a.nvim_buf_is_loaded(bufnr)
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.open(options)
|
function M.open(options)
|
||||||
@@ -230,7 +229,7 @@ function M.open(options)
|
|||||||
local should_redraw = false
|
local should_redraw = false
|
||||||
if not is_buf_valid(M.View.bufnr) then
|
if not is_buf_valid(M.View.bufnr) then
|
||||||
should_redraw = true
|
should_redraw = true
|
||||||
create_buffer()
|
M.create_buffer()
|
||||||
end
|
end
|
||||||
|
|
||||||
if not M.win_open() then
|
if not M.win_open() then
|
||||||
|
|||||||
Reference in New Issue
Block a user