fix: more graceful handling for when a colorscheme was not recognized

dev-doc
Pocco81 3 years ago
parent 6ad271002f
commit 5914d62d8b

@ -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

@ -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

@ -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

@ -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

Loading…
Cancel
Save