Skip to content

Commit

Permalink
fix: respect background variable on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
nullchilly committed Mar 24, 2024
1 parent 56fb982 commit 6b7a4df
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -90,6 +90,7 @@ There is no need to call `setup` if you don't want to change the default options
```lua
require("catppuccin").setup({
flavour = "mocha", -- latte, frappe, macchiato, mocha
-- flavour = "auto" -- will respect terminal's background
background = { -- :h background
light = "latte",
dark = "mocha",
Expand Down
1 change: 1 addition & 0 deletions doc/catppuccin.txt
Expand Up @@ -71,6 +71,7 @@ options and settings.
>lua
require("catppuccin").setup({
flavour = "mocha", -- latte, frappe, macchiato, mocha
-- flavour = "auto" -- will respect terminal's background
background = { -- :h background
light = "latte",
dark = "mocha",
Expand Down
7 changes: 7 additions & 0 deletions lua/catppuccin/init.lua
Expand Up @@ -135,6 +135,13 @@ end
local did_setup = false

function M.load(flavour)
if M.options.flavour == "auto" then -- set colorscheme based on o:background
M.options.flavour = nil -- ensure that this will only run once on startup
if not vim.api.nvim_get_option_info2("background", {}).was_set then -- wait for terminal to set o:background
vim.g.colors_name = "catppuccin"
return
end
end
if not did_setup then M.setup() end
M.flavour = get_flavour(flavour)
local compiled_path = M.options.compile_path .. M.path_sep .. M.flavour
Expand Down

0 comments on commit 6b7a4df

Please sign in to comment.