From 42caf517dd6876203d46f5a79b0c132e5f2e5718 Mon Sep 17 00:00:00 2001 From: EdenEast Date: Tue, 14 Feb 2023 16:33:15 -0500 Subject: [PATCH 1/2] fix(compiler): remove `require` call to write compiled files --- lua/catppuccin/lib/compiler.lua | 5 ++--- lua/catppuccin/lib/vim/compiler.lua | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/lua/catppuccin/lib/compiler.lua b/lua/catppuccin/lib/compiler.lua index 63439a15..3b2f0dc6 100644 --- a/lua/catppuccin/lib/compiler.lua +++ b/lua/catppuccin/lib/compiler.lua @@ -18,7 +18,7 @@ function M.compile(flavour) local theme = require("catppuccin.lib.mapper").apply(flavour) local lines = { [[ -require("catppuccin").compiled = string.dump(function() +return string.dump(function() if vim.g.colors_name then vim.cmd("hi clear") end vim.o.termguicolors = true vim.g.colors_name = "catppuccin"]], @@ -71,10 +71,9 @@ Below is the error message that we captured: dofile(err_path) return end - f() if file then - file:write(require("catppuccin").compiled) + file:write(f()) file:close() else print( diff --git a/lua/catppuccin/lib/vim/compiler.lua b/lua/catppuccin/lib/vim/compiler.lua index f0fe323a..f4dfc26c 100644 --- a/lua/catppuccin/lib/vim/compiler.lua +++ b/lua/catppuccin/lib/vim/compiler.lua @@ -9,7 +9,7 @@ function M.compile(flavour) local theme = require("catppuccin.lib.mapper").apply(flavour) local lines = { [[ -require("catppuccin").compiled = string.dump(function() +return string.dump(function() vim.command[[ if exists("colors_name") hi clear @@ -80,10 +80,9 @@ Below is the error message that we captured: dofile(err_path) return end - f() if file then - file:write(require("catppuccin").compiled) + file:write(f()) file:close() else print( From 927792ebb3a851ab3f889bec21591708a4f6e13a Mon Sep 17 00:00:00 2001 From: nullchilly Date: Wed, 15 Feb 2023 16:58:47 +0700 Subject: [PATCH 2/2] feat(compile): add catppuccin debug --- lua/catppuccin/lib/compiler.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lua/catppuccin/lib/compiler.lua b/lua/catppuccin/lib/compiler.lua index 3b2f0dc6..af1f11ad 100644 --- a/lua/catppuccin/lib/compiler.lua +++ b/lua/catppuccin/lib/compiler.lua @@ -52,9 +52,15 @@ vim.g.colors_name = "catppuccin"]], if vim.fn.isdirectory(O.compile_path) == 0 then vim.fn.mkdir(O.compile_path, "p") end local file = io.open(O.compile_path .. path_sep .. flavour .. "_compiled.lua", "wb") + if vim.g.catppuccin_debug then -- Debugging purpose + local deb = io.open((path_sep == "/" and "/tmp" or os.getenv "TMP") .. "/catppuccin_debug.lua", "wb") + deb:write(table.concat(lines, "\n")) + deb:close() + end + local f = loadstring(table.concat(lines, "\n"), "=") if not f then - local err_path = (path_sep == "/" and "/tmp" or os.getenv "TMP") .. "/catppuccin_error.lua" + local err_path = (path_sep == "/" and "/tmp" or os.getenv "TMP") .. "/catppuccin_debug.lua" print(string.format( [[Catppuccin (error): Most likely some mistake made in your catppuccin config You can open %s for debugging