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:
Azad 2023-09-26 00:41:23 +02:00 committed by GitHub
parent 07eb5b4059
commit ce3495bd4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -16,6 +16,12 @@ local find_file = require "nvim-tree.actions.tree.find-file"
local open = require "nvim-tree.actions.tree.open"
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 M = {
@ -736,7 +742,7 @@ local function validate_options(conf)
validate(conf, DEFAULT_OPTS, ACCEPTED_STRINGS, ACCEPTED_TYPES, "")
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
@ -759,7 +765,7 @@ end
function M.setup(conf)
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
end