From 2b32fb090fa09d68e8e5a222646979fa1d54f899 Mon Sep 17 00:00:00 2001 From: Hubert Pelczarski <41551030+hoob3rt@users.noreply.github.com> Date: Thu, 8 Apr 2021 04:06:31 -0700 Subject: [PATCH] fix: theme type check fix (#165) * fix: theme type check fix * fix: string concat bug * fix: removed semmicolon --- lua/lualine/init.lua | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/lua/lualine/init.lua b/lua/lualine/init.lua index bf62dbf..cedf3ab 100644 --- a/lua/lualine/init.lua +++ b/lua/lualine/init.lua @@ -266,23 +266,24 @@ end local function tabline() return statusline(config.tabline, true) end local function setup_theme() - local theme_name = config.options.theme - local ok, theme - if type(theme_name) == 'string' then - ok, theme = pcall(require, 'lualine.themes.' .. theme_name) - if not ok then - vim.api.nvim_echo({ - { - 'theme ' .. theme_name .. ' not found defaulting to gruvbox', - 'ErrorMsg' - } - }, true, {}) - theme = require 'lualine.themes.gruvbox' + local function get_theme_from_config() + local theme_name = config.options.theme + if type(theme_name) == 'string' then + local ok, theme = pcall(require, 'lualine.themes.' .. theme_name) + if ok then return theme end + elseif type(theme_name) == 'table' then + -- use the provided theme as-is + return config.options.theme end - else - -- use the provided theme as-is, assuming it's a dictionary - theme = config.options.theme + vim.api.nvim_echo({ + { + 'theme ' .. tostring(theme_name) .. ' not found, defaulting to gruvbox', + 'ErrorMsg' + } + }, true, {}) + return require 'lualine.themes.gruvbox' end + local theme = get_theme_from_config() highlight.create_highlight_groups(theme) vim.api.nvim_exec([[ augroup lualine