Skip to content

Commit

Permalink
feat(compile): error handling for vim
Browse files Browse the repository at this point in the history
  • Loading branch information
nullchilly committed Dec 1, 2022
1 parent 4c5a2eb commit be02956
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
16 changes: 10 additions & 6 deletions lua/catppuccin/lib/compiler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,20 @@ vim.g.colors_name = "catppuccin"]],

local f = loadstring(table.concat(lines, "\n"), "=")
if not f then
vim.notify(
local err_path = (path_sep == "/" and "/tmp" or os.getenv "TMP") .. "/catppuccin_error.lua"
print(string.format(
[[Catppuccin (error): Most likely some mistake made in your catppuccin config
You can open /tmp/catppuccin_error.lua for debugging
You can open %s for debugging
If you think this is a bug, kindly open an issue and attach /tmp/catppuccin_error.lua file
If you think this is a bug, kindly open an issue and attach %s file
Below is the error message that we captured:
]],
vim.log.levels.ERROR
)
io.open("/tmp/catppuccin_error.lua", "wb"):write(table.concat(lines, "\n"))
err_path,
err_path
))
local err = io.open(err_path, "wb")
err:write(table.concat(lines, "\n"))
err:close()
dofile "/tmp/catppuccin_error.lua"
return
end
Expand Down
22 changes: 21 additions & 1 deletion lua/catppuccin/lib/vim/compiler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,27 @@ let g:colors_name = "catppuccin"]],
end
local file = io.open(O.compile_path .. C.path_sep .. flavour .. "_compiled.lua", "wb")
local ls = load or loadstring
ls(table.concat(lines, "\n"), "=")()
local f = ls(table.concat(lines, "\n"), "=")
if not f then
local err_path = (C.path_sep == "/" and "/tmp" or os.getenv "TMP") .. "/catppuccin_error.lua"
print(string.format(
[[Catppuccin (error): Most likely some mistake made in your catppuccin config
You can open %s for debugging
If you think this is a bug, kindly open an issue and attach %s file
Below is the error message that we captured:
]],
err_path,
err_path
))
local err = io.open(err_path, "wb")
err:write(table.concat(lines, "\n"))
err:close()
dofile "/tmp/catppuccin_error.lua"
return
end
f()

file:write(require("catppuccin").compiled)
file:close()
end
Expand Down

0 comments on commit be02956

Please sign in to comment.