rcarriga / nvim-notify

A fancy, configurable, notification manager for NeoVim
MIT License
3.03k stars 81 forks source link

Text styling (color, bold, italic, underline etc) #266

Open gitaarik opened 6 months ago

gitaarik commented 6 months ago

This example image is used in the nvim-notify README.md:

image

I wonder how the g:my_cool_setting gets its orange color and how the code is highlighted. I wonder if it's possible to style text to give it a custom color make it bold or italic.

rcarriga commented 6 months ago

You can apply markdown highlighting as detailed in the README, which will allow injecting code blocks https://github.com/rcarriga/nvim-notify/blob/5371f4bfc1f6d3adf4fe9d62cd3a9d44356bfd15/README.md#L123-L129

gitaarik commented 6 months ago

Aha ok, yea I guess that's it, although I do see the backticks:

image
  local text = [[
    Test `g:my_cool_setting`
    ```lua
    print('hi')

]]

vim.notify(text, "info", { title = "My Awesome Plugin", on_open = function(win) local buf = vim.api.nvim_win_get_buf(win) vim.api.nvim_buf_set_option(buf, "filetype", "markdown") end, })



And it would be nice if you could manually set styles. For example if I have a option that I can toggle on / off, I would like to have the text be green or red. I don't want to use the "error" log level for "off", because it's not an error.
kiyoon commented 3 months ago

It took me years to find this, and finally I found it.

you can

require "notify"({ "`a` does not exist.", "```python", "print(a)", "```" }, "info", {
  title = "test",
  on_open = function(win)
    vim.wo[win].conceallevel = 3
    vim.wo[win].concealcursor = "n"
    vim.wo[win].spell = false
    vim.treesitter.start(vim.api.nvim_win_get_buf(win), "markdown")
  end,
})