Skip to content
Closed
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
1 change: 1 addition & 0 deletions lua/definitions/spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
---@class ui.config.message
---
---@field enable? boolean Should this module be enabled?
---@field notify? boolean Override `vim.notify` with ui.nvim messages (no replace)?
---@field respect_replace_last? boolean Should `replace_last` be respected?
---
---@field history_preference? "vim" | "ui" History preference for :messages
Expand Down
22 changes: 22 additions & 0 deletions lua/ui/message.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1274,6 +1274,28 @@ end
message.setup = function ()
---|fS

if spec.config.message.notify == true then
function vim.notify(msg, level, opts)
if level == vim.log.levels.OFF then
return;
end

if opts and opts.title then
msg = string.format("%s\n%s", opts.title, msg)
end

local hl
if level == vim.log.levels.ERROR then
hl = 'ErrorMsg'
elseif level == vim.log.levels.WARN then
hl = 'WarningMsg'
else
hl = 'Normal'
end
message.msg_show("", { {0, msg, vim.fn.hlID(hl)} }, false, true);
end
end

vim.api.nvim_create_autocmd("VimResized", {
callback = function ()
message.__list_resize();
Expand Down
1 change: 1 addition & 0 deletions lua/ui/spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,7 @@ spec.default = {
---|fS

enable = true,
notify = true,
respect_replace_last = true,

history_preference = "vim",
Expand Down