fix: schedule notifications to avoid UI freeze on startup (#2432)
* fix: schedule notifications to avoid UI freeze on startup * stylua
This commit is contained in:
parent
07eb5b4059
commit
ce3495bd4c
@ -16,6 +16,12 @@ local find_file = require "nvim-tree.actions.tree.find-file"
|
|||||||
local open = require "nvim-tree.actions.tree.open"
|
local open = require "nvim-tree.actions.tree.open"
|
||||||
local events = require "nvim-tree.events"
|
local events = require "nvim-tree.events"
|
||||||
|
|
||||||
|
local function notify_once(msg, level)
|
||||||
|
vim.schedule(function()
|
||||||
|
vim.notify_once(msg, level or vim.log.levels.WARN, { title = "NvimTree" })
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
local _config = {}
|
local _config = {}
|
||||||
|
|
||||||
local M = {
|
local M = {
|
||||||
@ -736,7 +742,7 @@ local function validate_options(conf)
|
|||||||
validate(conf, DEFAULT_OPTS, ACCEPTED_STRINGS, ACCEPTED_TYPES, "")
|
validate(conf, DEFAULT_OPTS, ACCEPTED_STRINGS, ACCEPTED_TYPES, "")
|
||||||
|
|
||||||
if msg then
|
if msg then
|
||||||
vim.notify_once(msg .. " | see :help nvim-tree-opts for available configuration options", vim.log.levels.WARN)
|
notify_once(msg .. " | see :help nvim-tree-opts for available configuration options")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -759,7 +765,7 @@ end
|
|||||||
|
|
||||||
function M.setup(conf)
|
function M.setup(conf)
|
||||||
if vim.fn.has "nvim-0.8" == 0 then
|
if vim.fn.has "nvim-0.8" == 0 then
|
||||||
vim.notify_once("nvim-tree.lua requires Neovim 0.8 or higher", vim.log.levels.WARN)
|
notify_once "nvim-tree.lua requires Neovim 0.8 or higher"
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user