From 48d1e8df12795cf559f704223b63e76259998582 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Tue, 10 Jan 2023 10:08:51 +0100 Subject: [PATCH] feat(util): use lazy's notify instead of `vim.notify` --- lua/lazyvim/plugins/lsp/format.lua | 8 +++++++- lua/lazyvim/util/init.lua | 28 +++++++++++----------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/lua/lazyvim/plugins/lsp/format.lua b/lua/lazyvim/plugins/lsp/format.lua index 01dabf4c..b30dcff7 100644 --- a/lua/lazyvim/plugins/lsp/format.lua +++ b/lua/lazyvim/plugins/lsp/format.lua @@ -1,10 +1,16 @@ +local Util = require("lazy.core.util") + local M = {} M.autoformat = true function M.toggle() M.autoformat = not M.autoformat - vim.notify(M.autoformat and "Enabled format on save" or "Disabled format on save") + if M.autoformat then + Util.info("Enabled format on save", { title = "Format" }) + else + Util.warn("Disabled format on save", { title = "Format" }) + end end function M.format() diff --git a/lua/lazyvim/util/init.lua b/lua/lazyvim/util/init.lua index cbf7611b..b198e7b4 100644 --- a/lua/lazyvim/util/init.lua +++ b/lua/lazyvim/util/init.lua @@ -1,3 +1,5 @@ +local Util = require("lazy.core.util") + local M = {} M.root_patterns = { ".git", "/lua" } @@ -95,19 +97,15 @@ function M.toggle(option, silent, values) else vim.opt_local[option] = values[1] end - return vim.notify( - "Set " .. option .. " to " .. vim.opt_local[option]:get(), - vim.log.levels.INFO, - { title = "Option" } - ) + return Util.info("Set " .. option .. " to " .. vim.opt_local[option]:get(), { title = "Option" }) end vim.opt_local[option] = not vim.opt_local[option]:get() if not silent then - vim.notify( - (vim.opt_local[option]:get() and "Enabled" or "Disabled") .. " " .. option, - vim.log.levels.INFO, - { title = "Option" } - ) + if vim.opt_local[option]:get() then + Util.info("Enabled " .. option, { title = "Option" }) + else + Util.warn("Disabled " .. option, { title = "Option" }) + end end end @@ -116,19 +114,15 @@ function M.toggle_diagnostics() enabled = not enabled if enabled then vim.diagnostic.enable() - vim.notify("Enabled diagnostics", vim.log.levels.INFO, { title = "Diagnostics" }) + Util.info("Enabled diagnostics", { title = "Diagnostics" }) else vim.diagnostic.disable() - vim.notify("Disabled diagnostics", vim.log.levels.INFO, { title = "Diagnostics" }) + Util.warn("Disabled diagnostics", { title = "Diagnostics" }) end end function M.deprecate(old, new) - vim.notify( - ("`%s` is deprecated. Please use `%s` instead"):format(old, new), - vim.log.levels.WARN, - { title = "LazyVim" } - ) + Util.warn(("`%s` is deprecated. Please use `%s` instead"):format(old, new), { title = "LazyVim" }) end return M