nvim-notify
nvim-notify copied to clipboard
Is it possible to show the title in the border?
I'm trying to change the renderer according to this. I know how to change the colors, I can change the message buffer renderer and I'd like to display the title in the border. Any idea??
on_open
now receives the notification record so you can use it for setting the title like so
notify.setup({
on_open = function(win, record)
vim.api.nvim_win_set_config(win, { title = record.title[1], title_pos = "center" })
end,
})
set_hl {
NotifyINFOBody = { bg = palette.surface0 },
NotifyINFOBorder = { bg = palette.surface0, fg = palette.surface0 },
NotifyINFOIcon = { bg = palette.surface0, fg = palette.green },
NotifyINFOTitle = { bg = palette.green, fg = palette.mantle },
NotifyWARNBody = { bg = palette.surface0 },
NotifyWARNBorder = { bg = palette.surface0, fg = palette.surface0 },
NotifyWARNIcon = { bg = palette.surface0, fg = palette.peach },
NotifyWARNTitle = { bg = palette.peach, fg = palette.mantle },
NotifyERRORBody = { bg = palette.surface0 },
NotifyERRORBorder = { bg = palette.surface0, fg = palette.surface0 },
NotifyERRORIcon = { bg = palette.surface0, fg = palette.red },
NotifyERRORTitle = { bg = palette.red, fg = palette.mantle }
}
local renderbase = require("notify.render.base")
require("notify").setup {
on_open = function(win, record)
vim.api.nvim_win_set_config(win, {
border = "solid",
title = {
{
" " .. record.title[1] .. " ",
"Notify" .. record.level .. "Title"
}
},
title_pos = "center"
})
end,
render = function(bufnr, notif, highlights)
local namespace = renderbase.namespace()
local length = string.len(notif.icon)
notif.message[1] = string.format("%s %s", notif.icon, notif.message[1])
vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, notif.message)
vim.api.nvim_buf_set_extmark(bufnr, namespace, 0, 0, {
hl_group = highlights.icon,
end_col = length,
priority = 50
})
vim.api.nvim_buf_set_extmark(bufnr, namespace, 0, length, {
hl_group = highlights.body,
end_line = #notif.message,
priority = 50
})
end
}
@rcarriga Any idea why the message type (record.level
) is wrong here?
- open new
nvim
- exec
:PackerUpdate
- try to save the file (
:w
)
@rcarriga https://pasteboard.co/RFDUpBusMntk.png