Skip to content

Commit 666134a

Browse files
committed
fix: check if vim.g.colors_name is nil.
This commit want to avoid the case when `get_palette()` call happens before `vim.g.colors_name` be initialized, which will raise error.
1 parent 02aff10 commit 666134a

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lua/modules/utils/init.lua

+6-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ local M = {}
2929
---@field crust string
3030
---@field none "NONE"
3131

32-
---@type nil|palette
32+
---@type nil|table
3333
local palette = nil
3434

3535
-- Indicates if autocmd for refreshing the builtin palette has already been registered
@@ -57,8 +57,8 @@ local function init_palette()
5757
end
5858

5959
if not palette then
60-
palette = vim.g.colors_name:find("catppuccin") and require("catppuccin.palettes").get_palette()
61-
or {
60+
if vim.g.colors_name == nil then
61+
palette = {
6262
rosewater = "#DC8A78",
6363
flamingo = "#DD7878",
6464
mauve = "#CBA6F7",
@@ -88,6 +88,9 @@ local function init_palette()
8888
mantle = "#1C1C19",
8989
crust = "#161320",
9090
}
91+
elseif vim.g.colors_name:find("catppuccin") then
92+
palette = require("catppuccin.palettes").get_palette()
93+
end
9194

9295
palette = vim.tbl_extend("force", { none = "NONE" }, palette, require("core.settings").palette_overwrite)
9396
end

0 commit comments

Comments
 (0)