Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT] Enable Setting Themes by Strings in Addition to Custom Themes Dynamically #1353

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions lua/lualine.lua
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,20 @@ local function setup_theme()
-- use the provided theme as-is
return config.options.theme
elseif type(theme_name) == 'function' then
-- call function and use returned (dynamic) theme as-is
return config.options.theme()
-- call function and use returned (dyanmic) theme, either as-is or as a string
local ok, dynamic_theme = pcall(theme_name)
if ok and (type(dynamic_theme) == 'string') then
local ok_string, theme = pcall(modules.loader.load_theme, dynamic_theme)
if ok_string and theme then
return theme
end
elseif ok and (type(dynamic_theme) == 'table') then
return dynamic_theme
else
local error_message = 'Invalid theme type returned from function: ' .. type(dynamic_theme)
notify_theme_error(error_message)
return dynamic_theme
end
end
if theme_name ~= 'auto' then
notify_theme_error(theme_name)
Expand Down