fix: don't show notification for empty LualineNotice

Previously even if config error was resolved in following setup call
notification for LualineNotice was displayed and when user opened
LualineNotice it'll be empty leaving users confused.

Now we'll wait for 2s before sending notification for LualineNotice so
if successive calls to setup fixed the config error the notification
will not be shown.
This commit is contained in:
shadmansaleh 2022-07-28 13:03:10 +06:00
parent 8a9c97d111
commit aeeefcef98
1 changed files with 11 additions and 5 deletions

View File

@ -28,17 +28,23 @@ end
---show setup :LuaLineNotices and show notification about error when there ---show setup :LuaLineNotices and show notification about error when there
---are notices available ---are notices available
local notify_done = false
function M.notice_message_startup() function M.notice_message_startup()
if #notices > 0 or #persistent_notices > 0 then notify_done = false
vim.cmd('command! -nargs=0 LualineNotices lua require"lualine.utils.notices".show_notices()') vim.defer_fn(function()
vim.schedule(function() if notify_done then
return
end
if #notices > 0 or #persistent_notices > 0 then
vim.cmd('command! -nargs=0 LualineNotices lua require"lualine.utils.notices".show_notices()')
vim.notify( vim.notify(
'lualine: There are some issues with your config. Run :LualineNotices for details', 'lualine: There are some issues with your config. Run :LualineNotices for details',
vim.log.levels.WARN, vim.log.levels.WARN,
{} {}
) )
end) end
end notify_done = true
end, 2000)
end end
---create notice view ---create notice view