diff --git a/lua/catppuccino/core/cs.lua b/lua/catppuccino/core/cs.lua index a448664..be5596b 100644 --- a/lua/catppuccino/core/cs.lua +++ b/lua/catppuccino/core/cs.lua @@ -12,10 +12,16 @@ end function M.get_color_scheme(cs) local remaps = M.get_remaps() + local good, color_scheme = pcall(require, "catppuccino.color_schemes." .. cs) + + if not good then + return false, "Catppuccino: the colorscheme '" .. cs .. "' was not recognized." + end + if not (next(remaps) == nil) then - return vim.tbl_deep_extend("force", require("catppuccino.color_schemes." .. cs), remaps) + return true, vim.tbl_deep_extend("force", color_scheme, remaps) else - return require("catppuccino.color_schemes." .. cs) + return true, color_scheme end end diff --git a/lua/catppuccino/core/mapper.lua b/lua/catppuccino/core/mapper.lua index e275a6a..d1e82e2 100644 --- a/lua/catppuccino/core/mapper.lua +++ b/lua/catppuccino/core/mapper.lua @@ -187,8 +187,14 @@ end function M.apply(cs) _G.cpc = require("catppuccino.config").options cs = cs or cpc.colorscheme - -- _G.cpt = require("catppuccino.color_schemes." .. cs) - _G.cpt = require("catppuccino.core.cs").get_color_scheme(cs) + local good, color_scheme = require("catppuccino.core.cs").get_color_scheme(cs) + + if not good then + print(color_scheme) -- error message + return + end + + _G.cpt = color_scheme local theme = {} theme.base = get_base() diff --git a/lua/lightline/colorscheme/catppuccino.lua b/lua/lightline/colorscheme/catppuccino.lua index 665c2c9..f95ada1 100644 --- a/lua/lightline/colorscheme/catppuccino.lua +++ b/lua/lightline/colorscheme/catppuccino.lua @@ -1,4 +1,11 @@ -local cpt = require("catppuccino.core.cs").get_color_scheme(require("catppuccino.config").options["cptcheme"]) +local good, color_scheme = require("catppuccino.core.cs").get_color_scheme(require("catppuccino.config").options["cptcheme"]) + +if not good then + print(color_scheme) -- error message + return +end + +local cpt = color_scheme local catppuccino = {} catppuccino.normal = { diff --git a/lua/lualine/themes/catppuccino.lua b/lua/lualine/themes/catppuccino.lua index 0fd4852..9d2c187 100644 --- a/lua/lualine/themes/catppuccino.lua +++ b/lua/lualine/themes/catppuccino.lua @@ -1,4 +1,11 @@ -local cpt = require("catppuccino.core.cs").get_color_scheme(require("catppuccino.config").options["colorscheme"]) +local good, color_scheme = require("catppuccino.core.cs").get_color_scheme(require("catppuccino.config").options["cptcheme"]) + +if not good then + print(color_scheme) -- error message + return +end + +local cpt = color_scheme local catppuccino = {} catppuccino.normal = {