From ce3495bd4c9a7d8e8a64fac9cc3c252dac19a994 Mon Sep 17 00:00:00 2001 From: Azad <49314270+Akmadan23@users.noreply.github.com> Date: Tue, 26 Sep 2023 00:41:23 +0200 Subject: [PATCH] fix: schedule notifications to avoid UI freeze on startup (#2432) * fix: schedule notifications to avoid UI freeze on startup * stylua --- lua/nvim-tree.lua | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lua/nvim-tree.lua b/lua/nvim-tree.lua index 86e5ba0e..ee46780e 100644 --- a/lua/nvim-tree.lua +++ b/lua/nvim-tree.lua @@ -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