fixed highlight bug (#19)

* fixed live colorscheme change also applying to lualine
* fixed theme definition in config not working
This commit is contained in:
hoob3rt 2021-01-04 01:17:51 +01:00 committed by GitHub
parent 0194740d28
commit 3ab7066718
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 10 deletions

View File

@ -4,6 +4,7 @@ local highlight = require('lualine.highlight')
local M = { }
M.theme = 'gruvbox'
local theme_set = {}
M.separator = '|'
@ -57,14 +58,21 @@ local function loadExtensions()
end
end
local function setLualineTheme()
if type(M.theme) == 'string' then
M.theme =require('lualine.themes.'.. M.theme)
end
highlight.createHighlightGroups(M.theme)
theme_set = M.theme
end
local function StatusLine(isFocused)
local sections = M.sections
if not isFocused then
sections = M.inactiveSections
end
if type(M.theme) == 'string' then
M.theme = utils.setTheme(M.theme)
highlight.createHighlightGroups(M.theme)
if M.theme ~= theme_set then
setLualineTheme()
end
local status = {}
if sections.lualine_a ~= nil then
@ -95,12 +103,19 @@ local function StatusLine(isFocused)
return table.concat(status)
end
function execAutocommands()
_G.statusline = StatusLine
_G.highlight = setLualineTheme
vim.cmd([[autocmd WinEnter,BufEnter * setlocal statusline=%!v:lua.statusline(1)]])
vim.cmd([[autocmd WinLeave,BufLeave * setlocal statusline=%!v:lua.statusline()]])
vim.cmd([[autocmd ColorScheme * call v:lua.highlight()]])
end
function M.status()
loadComponents()
loadExtensions()
_G.statusline = StatusLine
vim.cmd([[autocmd WinEnter,BufEnter * setlocal statusline=%!v:lua.statusline(1)]])
vim.cmd([[autocmd WinLeave,BufLeave * setlocal statusline=%!v:lua.statusline()]])
setLualineTheme()
execAutocommands()
end
return M

View File

@ -1,9 +1,5 @@
local M = { }
function M.setTheme(theme)
return require('lualine.themes.'..theme)
end
function M.drawSection(section, separator)
local status = {}
for _, statusFunction in pairs(section) do