Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lua/one_monokai/colors.lua
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ local function get_hex_value(name, value)
})

if not type_ok then
logs.notify.error(err)
logs.error(err)

return defaults[name]
end
Expand All @@ -93,7 +93,7 @@ local function get_hex_value(name, value)
local rgb = vim.api.nvim_get_color_by_name(value)

if rgb == -1 then
logs.notify.error("colors(%s): %q is not a valid color", name, value)
logs.error("colors(%s): %q is not a valid color", name, value)

return defaults[name]
end
Expand Down
2 changes: 1 addition & 1 deletion lua/one_monokai/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function config.extend(opts)
local logs = require "one_monokai.logs"

if opts.themes then
logs.notify.warning(
logs.warning(
"config: %q option has been deprecated and will be removed soon. Please update your config to use %q instead.",
"themes",
"highlights"
Expand Down
2 changes: 1 addition & 1 deletion lua/one_monokai/highlights/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ local function set_highlight(groups)
local status_ok, err = pcall(set_hl, 0, name, attrs)

if not status_ok then
logs.notify.error("highlights(%s): %s", name, err)
logs.error("highlights(%s): %s", name, err)
end
end
end
Expand Down
33 changes: 18 additions & 15 deletions lua/one_monokai/logs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,29 @@
local logs = {}

---Display a notification to the user
---@param log_level string
---@param s string
local function notify(log_level, s, ...)
---@param level vim.log.levels
---@param s string|number
---@param ... any
local function notify(level, s, ...)
local message = string.format(s, ...)

vim.notify_once(message, log_level, {
vim.notify(message, level, {
title = "One Monokai",
})
end

---@class notify
---@field error fun(s:string, ...) #Show error message
---@field warning fun(s: string, ...) #Show warning message
logs.notify = {
error = function(s, ...)
notify(vim.log.levels.ERROR, s, ...)
end,
warning = function(s, ...)
notify(vim.log.levels.WARNING, s, ...)
end,
}
---Display an error message to the user
---@param s string|number
---@param ... any
logs.error = function(s, ...)
notify(vim.log.levels.ERROR, s, ...)
end

---Display a warning message to the user
---@param s string|number
---@param ... any
logs.warning = function(s, ...)
notify(vim.log.levels.WARN, s, ...)
end

return logs
Loading