feat(util): use lazy's notify instead of vim.notify

This commit is contained in:
Folke Lemaitre 2023-01-10 10:08:51 +01:00
parent 04a898a326
commit 48d1e8df12
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
2 changed files with 18 additions and 18 deletions

View file

@ -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()

View file

@ -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