fixed highlight bug (#19)
* fixed live colorscheme change also applying to lualine * fixed theme definition in config not working
This commit is contained in:
parent
0194740d28
commit
3ab7066718
|
@ -4,6 +4,7 @@ local highlight = require('lualine.highlight')
|
||||||
local M = { }
|
local M = { }
|
||||||
|
|
||||||
M.theme = 'gruvbox'
|
M.theme = 'gruvbox'
|
||||||
|
local theme_set = {}
|
||||||
|
|
||||||
M.separator = '|'
|
M.separator = '|'
|
||||||
|
|
||||||
|
@ -57,14 +58,21 @@ local function loadExtensions()
|
||||||
end
|
end
|
||||||
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 function StatusLine(isFocused)
|
||||||
local sections = M.sections
|
local sections = M.sections
|
||||||
if not isFocused then
|
if not isFocused then
|
||||||
sections = M.inactiveSections
|
sections = M.inactiveSections
|
||||||
end
|
end
|
||||||
if type(M.theme) == 'string' then
|
if M.theme ~= theme_set then
|
||||||
M.theme = utils.setTheme(M.theme)
|
setLualineTheme()
|
||||||
highlight.createHighlightGroups(M.theme)
|
|
||||||
end
|
end
|
||||||
local status = {}
|
local status = {}
|
||||||
if sections.lualine_a ~= nil then
|
if sections.lualine_a ~= nil then
|
||||||
|
@ -95,12 +103,19 @@ local function StatusLine(isFocused)
|
||||||
return table.concat(status)
|
return table.concat(status)
|
||||||
end
|
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()
|
function M.status()
|
||||||
loadComponents()
|
loadComponents()
|
||||||
loadExtensions()
|
loadExtensions()
|
||||||
_G.statusline = StatusLine
|
setLualineTheme()
|
||||||
vim.cmd([[autocmd WinEnter,BufEnter * setlocal statusline=%!v:lua.statusline(1)]])
|
execAutocommands()
|
||||||
vim.cmd([[autocmd WinLeave,BufLeave * setlocal statusline=%!v:lua.statusline()]])
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
local M = { }
|
local M = { }
|
||||||
|
|
||||||
function M.setTheme(theme)
|
|
||||||
return require('lualine.themes.'..theme)
|
|
||||||
end
|
|
||||||
|
|
||||||
function M.drawSection(section, separator)
|
function M.drawSection(section, separator)
|
||||||
local status = {}
|
local status = {}
|
||||||
for _, statusFunction in pairs(section) do
|
for _, statusFunction in pairs(section) do
|
||||||
|
|
Loading…
Reference in New Issue