Skip to content

Commit

Permalink
feat(util): use lazy's notify instead of vim.notify
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Jan 10, 2023
1 parent 04a898a commit 48d1e8d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
8 changes: 7 additions & 1 deletion lua/lazyvim/plugins/lsp/format.lua
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
28 changes: 11 additions & 17 deletions lua/lazyvim/util/init.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
local Util = require("lazy.core.util")

local M = {}

M.root_patterns = { ".git", "/lua" }
Expand Down Expand Up @@ -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

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

0 comments on commit 48d1e8d

Please sign in to comment.