Remove new_async():send() pattern + restructure augroup

This does not load load lualine asyncronasly rather fools the profilers
In addition causes issues like intro disapearing
This commit is contained in:
shadmansaleh 2021-08-02 21:16:17 +06:00
parent 7a45a4f7fe
commit 486be4462f
3 changed files with 44 additions and 52 deletions

View File

@ -18,7 +18,7 @@ Branch.new = function(self, options, child)
-- run watch head on load so branch is present when component is loaded
Branch.update_branch()
-- update branch state of BufEnter as different Buffer may be on different repos
vim.cmd [[autocmd BufEnter * lua require'lualine.components.branch'.update_branch()]]
vim.cmd [[autocmd lualine BufEnter * lua require'lualine.components.branch'.update_branch()]]
return new_branch
end

View File

@ -167,9 +167,6 @@ end
local function tabline() return statusline(config.tabline, true) end
local function setup_theme()
local async_loader
async_loader = vim.loop.new_async(vim.schedule_wrap(
function()
local function get_theme_from_config()
local theme_name = config.options.theme
if type(theme_name) == 'string' then
@ -186,14 +183,9 @@ local function setup_theme()
end
local theme = get_theme_from_config()
highlight.create_highlight_groups(theme)
vim.api.nvim_exec([[
augroup lualine
autocmd ColorScheme * lua require'lualine.utils.utils'.reload_highlights()
augroup END
]], false)
async_loader:close()
end))
async_loader:send()
vim.cmd [[
autocmd lualine ColorScheme * lua require'lualine.utils.utils'.reload_highlights()
]]
end
local function set_tabline()
@ -207,16 +199,21 @@ local function set_statusline()
if next(config.sections) ~= nil or next(config.inactive_sections) ~= nil then
vim.o.statusline = '%!v:lua.require\'lualine\'.statusline()'
vim.api.nvim_exec([[
augroup lualine
autocmd!
autocmd WinLeave,BufLeave * lua vim.wo.statusline=require'lualine'.statusline()
autocmd BufWinEnter,WinEnter,BufEnter,SessionLoadPost * set statusline<
autocmd VimResized * redrawstatus
augroup END
autocmd lualine WinLeave,BufLeave * lua vim.wo.statusline=require'lualine'.statusline()
autocmd lualine BufWinEnter,WinEnter,BufEnter,SessionLoadPost * set statusline<
autocmd lualine VimResized * redrawstatus
]], false)
end
end
local function setup_augroup()
vim.cmd [[
augroup lualine
autocmd!
augroup END
]]
end
local function setup(user_config)
if user_config then
config = config_module.apply_configuration(user_config)
@ -229,6 +226,7 @@ local function setup(user_config)
else
config = config_module.apply_configuration({})
end
setup_augroup()
setup_theme()
loader.load_all(config)
set_statusline()

View File

@ -24,9 +24,6 @@ local function component_loader(component)
end
local function load_sections(sections, options)
local async_loader
async_loader = vim.loop.new_async(vim.schedule_wrap(
function()
for section_name, section in pairs(sections) do
for index, component in pairs(section) do
if type(component) == 'string' or type(component) == 'function' then
@ -39,9 +36,6 @@ local function load_sections(sections, options)
section[index] = component_loader(component)
end
end
async_loader:close()
end))
async_loader:send()
end
local function load_components(config)