From 718dcc79e606edf475a335f9d97fcc45b1a8145b Mon Sep 17 00:00:00 2001 From: ViViDboarder Date: Thu, 16 Dec 2021 20:51:13 -0800 Subject: [PATCH] Fix colorscheme setting on first load --- neovim/lua/_colors.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/neovim/lua/_colors.lua b/neovim/lua/_colors.lua index 54cacc5..e71863f 100644 --- a/neovim/lua/_colors.lua +++ b/neovim/lua/_colors.lua @@ -6,7 +6,11 @@ function _G.update_colors() if changed or force then if scope == "g" and name == "colors_name" then -- Colorscheme is different. Use this instead of setting colors_name directly - vim.cmd("colorscheme " .. val) + -- Try to set the colorscheme. If not loaded, skip the error + local status, _ = pcall(vim.cmd, "colorscheme " .. val) + if not status then + vim.notify("Failed to set colorscheme to " .. val .. ". Maybe it's not yet loaded") + end else vim[scope][name] = val end