From f9a412002f753e13e5f97b9f7bbf758da3aac1cc Mon Sep 17 00:00:00 2001 From: Pocco81 Date: Mon, 11 Jul 2022 21:31:57 -0500 Subject: [PATCH] added echo utility --- lua/catppuccin/utils/echo.lua | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 lua/catppuccin/utils/echo.lua diff --git a/lua/catppuccin/utils/echo.lua b/lua/catppuccin/utils/echo.lua new file mode 100644 index 0000000..adee6ed --- /dev/null +++ b/lua/catppuccin/utils/echo.lua @@ -0,0 +1,21 @@ +local TITLE = "Catppuccin" + +return function(msg, level) + local has_notify_plugin = pcall(require, "notify") + + if level == "error" then + level = vim.log.levels.ERROR + elseif level == "warn" then + level = vim.log.levels.WARN + else + level = level or vim.log.levels.INFO + end + + if has_notify_plugin then + vim.notify(msg, level, { + title = TITLE, + }) + else + vim.notify(("[%s] %s"):format(TITLE, msg), level) + end +end