diff --git a/lua/catppuccino/core/cs.lua b/lua/catppuccino/core/cs.lua index 2605af6..a987043 100644 --- a/lua/catppuccino/core/cs.lua +++ b/lua/catppuccino/core/cs.lua @@ -15,13 +15,13 @@ function M.get_color_scheme(cs) local good, color_scheme = pcall(require, "catppuccino.color_schemes." .. cs) if not good then - return false, "Catppuccino: the colorscheme '" .. cs .. "' was not recognized." + return {status = false, msg = "Catppuccino: the colorscheme '" .. cs .. "' was not recognized. Defaulting to Catppuccino Dark."}, require("catppuccino.color_schemes.catppuccino") end if not (next(remaps) == nil) then - return true, vim.tbl_deep_extend("force", color_scheme, remaps) + return {status = true}, vim.tbl_deep_extend("force", color_scheme, remaps) else - return true, color_scheme + return {status = true}, color_scheme end end diff --git a/lua/catppuccino/core/mapper.lua b/lua/catppuccino/core/mapper.lua index 83f828b..7a9a98a 100644 --- a/lua/catppuccino/core/mapper.lua +++ b/lua/catppuccino/core/mapper.lua @@ -202,10 +202,10 @@ end function M.apply(cs) _G.cpc = require("catppuccino.config").options cs = cs or cpc.colorscheme - local good, color_scheme = require("catppuccino.core.cs").get_color_scheme(cs) + local err, color_scheme = require("catppuccino.core.cs").get_color_scheme(cs) - if not good then - return false, color_scheme -- error message + if not err.status then + vim.api.nvim_err_writeln(err.msg) end set_cs(color_scheme) @@ -217,7 +217,7 @@ function M.apply(cs) -- uninstantiate to avoid poluting global scope and because they are not needed anymore _G.cpc = nil - return true, theme + return theme end return M diff --git a/lua/catppuccino/main.lua b/lua/catppuccino/main.lua index 0a77c99..a8396de 100644 --- a/lua/catppuccino/main.lua +++ b/lua/catppuccino/main.lua @@ -9,13 +9,7 @@ local function load(args) catppuccino.before_loading() end - local good, theme = require("catppuccino.core.mapper").apply(args) - - if not good then - print(theme) -- error message - return - end - + local theme = require("catppuccino.core.mapper").apply(args) utils.load(theme) if (catppuccino.after_loading ~= nil) then diff --git a/lua/lualine/themes/catppuccino.lua b/lua/lualine/themes/catppuccino.lua index 6865f2f..c512927 100644 --- a/lua/lualine/themes/catppuccino.lua +++ b/lua/lualine/themes/catppuccino.lua @@ -1,8 +1,7 @@ -local good, color_scheme = require("catppuccino.core.cs").get_color_scheme(require("catppuccino.config").options["colorscheme"]) +local err, color_scheme = require("catppuccino.core.cs").get_color_scheme(require("catppuccino.config").options["colorscheme"]) -if not good then - print(color_scheme) -- error message - return +if not err.status then + vim.api.nvim_err_writeln(err.msg) end local cpt = color_scheme