Skip to content

Commit

Permalink
fix: display icon on notices for nvim-notify
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisgrieser committed Nov 21, 2024
1 parent 1bac279 commit 34f595f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ require("rip-substitute").setup {
},
notification = {
onSuccess = true,
icon = "", -- requires `snacks.nvim`
icon = "",
}
}
```
Expand Down
2 changes: 1 addition & 1 deletion lua/rip-substitute/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ local defaultConfig = {
},
notification = {
onSuccess = true,
icon = "", -- requires `snacks.nvim`
icon = "",
},
}

Expand Down
7 changes: 6 additions & 1 deletion lua/rip-substitute/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ local M = {}
function M.notify(msg, level)
if not level then level = "info" end
local icon = require("rip-substitute.config").config.notification.icon
vim.notify(msg, vim.log.levels[level:upper()], { title = "rip-substitute", icon = icon })
local opts = { title = "rip-substitute", icon = icon }

-- since nvim-notify does not support the `icon` field that snacks.nvim
if package.loaded["notify"] then opts.title = vim.trim(icon .. opts.title) end

vim.notify(msg, vim.log.levels[level:upper()], opts)
end

---@return number startLnum
Expand Down

0 comments on commit 34f595f

Please sign in to comment.