rcarriga / nvim-notify

A fancy, configurable, notification manager for NeoVim
MIT License
2.91k stars 74 forks source link

Possible to use hlgroups in a notify call, or otherwise colorize things ad hoc? #230

Open prurph opened 8 months ago

prurph commented 8 months ago

I'd like to create a notification that uses hlgroups to highlight various lines of hardcoded text, something like:

require("notify")("Some default text %#Error# these words have the Error hlgroup")

as a quick and dirty way to format different words in a notification ad hoc. My use case is I want to bind a popup that will remind me what some icons in my file explorer mean, and it would be cool if I could color each with their specific hlgroup, or even just match the correct color somehow. The notification text would be hardcoded.

Is this possible? Thanks!

Wouldn't it be cool if these were each colored appropriately!? 💅

Screenshot 2023-11-18 at 1 06 52 PM
prurph commented 8 months ago

As a hack I can create a scratch buffer that looks like I want and then replace the notify buffer in the on_open, but that destroys the title of the notification. I tried to capture the notification lines by using vim.api.nvim_buf_get_lines on the notification buffer before I replaced it, but that didn't work either.

Is there a way to provide a buffer to use as the notification body? Unfortunately passing just the lines of the buffer (from vim.api.nvim_buf_get_lines) discards any highlighting.