Skip to content

Commit

Permalink
fix: check if vim.g.colors_name is nil. (ayamir#1369)
Browse files Browse the repository at this point in the history
This commit want to avoid the case when `get_palette()` call happens
before `vim.g.colors_name` be initialized, which will raise error.
  • Loading branch information
ayamir authored Nov 22, 2024
1 parent 82919e8 commit a631be2
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lua/modules/utils/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ local M = {}
---@field crust string
---@field none "NONE"

---@type nil|palette
---@type nil|table
local palette = nil

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

if not palette then
palette = vim.g.colors_name:find("catppuccin") and require("catppuccin.palettes").get_palette()
or {
if vim.g.colors_name == nil then
palette = {
rosewater = "#DC8A78",
flamingo = "#DD7878",
mauve = "#CBA6F7",
Expand Down Expand Up @@ -88,6 +88,9 @@ local function init_palette()
mantle = "#1C1C19",
crust = "#161320",
}
elseif vim.g.colors_name:find("catppuccin") then
palette = require("catppuccin.palettes").get_palette()
end

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

0 comments on commit a631be2

Please sign in to comment.