Skip to content

Keyboard shortcut to toggle transparent background #404

Answered by EdenEast
eXvimmer asked this question in Q&A
Discussion options

You must be logged in to vote

Here is an example solution:

vim.keymap.set("n", "<leader>tt", function()
  local cat = require("catppuccin")
  cat.options.transparent_background = not cat.options.transparent_background
  cat.compile()
  vim.cmd.colorscheme(vim.g.colors_name)
end)

Note that this will invalidate the cache file vs the compiled files.

local cached_path = M.options.compile_path .. M.path_sep .. "date.txt"
local file = io.open(cached_path)
local cached = nil
if file then
cached = file:read()
file:close()
end
local git_path = debug.getinfo(1).source:sub(2, -24) .. ".git" .. M.path_sep .. "ORIG_HEAD"

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@eXvimmer
Comment options

Answer selected by eXvimmer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants