From b0da16addd3e6bffaacc5b48e72d7fe8403ffbdf Mon Sep 17 00:00:00 2001 From: shadmansaleh <13149513+shadmansaleh@users.noreply.github.com> Date: Mon, 30 Aug 2021 18:22:02 +0600 Subject: [PATCH] enhance:Don't load notice module when there are no notices --- lua/lualine/init.lua | 8 ++++++-- lua/lualine/utils/loader.lua | 8 +++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lua/lualine/init.lua b/lua/lualine/init.lua index b3b4fc8..e99bb95 100644 --- a/lua/lualine/init.lua +++ b/lua/lualine/init.lua @@ -246,13 +246,17 @@ local function setup_augroup() end local function reset_lualine() - modules.utils_notices.clear_notices() + if package.loaded['lualine.utils.notices'] then + modules.utils_notices.clear_notices() + end setup_augroup() setup_theme() modules.loader.load_all(config) set_statusline() set_tabline() - modules.utils_notices.notice_message_startup() + if package.loaded['lualine.utils.notices'] then + modules.utils_notices.notice_message_startup() + end new_config = nil end diff --git a/lua/lualine/utils/loader.lua b/lua/lualine/utils/loader.lua index f24fefa..04cd3df 100644 --- a/lua/lualine/utils/loader.lua +++ b/lua/lualine/utils/loader.lua @@ -3,7 +3,9 @@ local lualine_require = require'lualine_require' local require = lualine_require.require -local notice = require'lualine.utils.notices' +local modules = lualine_require.lazy_require{ + notice = 'lualine.utils.notices', +} local is_valid_filename = lualine_require.is_valid_filename local sep = package.config:sub(1,1) @@ -49,7 +51,7 @@ local function component_loader(component) elseif component.type == 'vimf' or component.type == 'luae' then return component_types['_'](component) else - notice.add_notice(string.format([[ + modules.notice.add_notice(string.format([[ ### component.type component type '%s' isn't recognised. Check if spelling is correct.]], component.type)) @@ -105,7 +107,7 @@ local function load_extensions(config) end table.insert(loaded_extensions, local_extension) else - notice.add_notice(string.format([[ + modules.notice.add_notice(string.format([[ ### Extensions Extension named `%s` was not found . Check if spelling is correct. ]], extension))