This commit is contained in:
Shadman 2021-02-05 18:29:34 +06:00 committed by GitHub
parent 66ab809e0e
commit e37b3ac929
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 13 deletions

View File

@ -65,14 +65,7 @@ local function set_lualine_theme()
theme_set = M.theme theme_set = M.theme
end end
local function statusline(is_focused) local function statusline(sections, is_focused)
local sections = M.sections
if not is_focused then
sections = M.inactive_sections
end
if M.theme ~= theme_set then
set_lualine_theme()
end
local status = {} local status = {}
if sections.lualine_a then if sections.lualine_a then
table.insert(status, highlight.format_highlight(is_focused, 'lualine_a')) table.insert(status, highlight.format_highlight(is_focused, 'lualine_a'))
@ -102,18 +95,19 @@ local function statusline(is_focused)
return table.concat(status) return table.concat(status)
end end
function M.set_inactive_statusline() local function status_dispatch()
vim.wo.statusline = statusline() if vim.g.statusline_winid == vim.fn.win_getid() then
return statusline(M.sections, true)
else
return statusline(M.inactive_sections, false)
end
end end
local function exec_autocommands() local function exec_autocommands()
_G.set_lualine_theme = set_lualine_theme _G.set_lualine_theme = set_lualine_theme
_G.set_active_statusline = statusline
vim.api.nvim_exec([[ vim.api.nvim_exec([[
augroup lualine augroup lualine
autocmd! autocmd!
autocmd WinEnter,BufEnter * setlocal statusline=%!v:lua.set_active_statusline(1)
autocmd WinLeave,BufLeave * lua require('lualine').set_inactive_statusline()
autocmd ColorScheme * call v:lua.set_lualine_theme() autocmd ColorScheme * call v:lua.set_lualine_theme()
augroup END augroup END
]], false) ]], false)
@ -124,6 +118,8 @@ function M.status()
load_extensions() load_extensions()
set_lualine_theme() set_lualine_theme()
exec_autocommands() exec_autocommands()
_G.lualine_statusline = status_dispatch
vim.o.statusline = '%!v:lua.lualine_statusline()'
end end
return M return M