Skip to content

Commit ce3495b

Browse files
authored
fix: schedule notifications to avoid UI freeze on startup (#2432)
* fix: schedule notifications to avoid UI freeze on startup * stylua
1 parent 07eb5b4 commit ce3495b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lua/nvim-tree.lua

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ local find_file = require "nvim-tree.actions.tree.find-file"
1616
local open = require "nvim-tree.actions.tree.open"
1717
local events = require "nvim-tree.events"
1818

19+
local function notify_once(msg, level)
20+
vim.schedule(function()
21+
vim.notify_once(msg, level or vim.log.levels.WARN, { title = "NvimTree" })
22+
end)
23+
end
24+
1925
local _config = {}
2026

2127
local M = {
@@ -736,7 +742,7 @@ local function validate_options(conf)
736742
validate(conf, DEFAULT_OPTS, ACCEPTED_STRINGS, ACCEPTED_TYPES, "")
737743

738744
if msg then
739-
vim.notify_once(msg .. " | see :help nvim-tree-opts for available configuration options", vim.log.levels.WARN)
745+
notify_once(msg .. " | see :help nvim-tree-opts for available configuration options")
740746
end
741747
end
742748

@@ -759,7 +765,7 @@ end
759765

760766
function M.setup(conf)
761767
if vim.fn.has "nvim-0.8" == 0 then
762-
vim.notify_once("nvim-tree.lua requires Neovim 0.8 or higher", vim.log.levels.WARN)
768+
notify_once "nvim-tree.lua requires Neovim 0.8 or higher"
763769
return
764770
end
765771

0 commit comments

Comments
 (0)