nvim-notify icon indicating copy to clipboard operation
nvim-notify copied to clipboard

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

Open gitaarik opened this issue 1 year ago • 3 comments

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.

gitaarik avatar Apr 03 '24 09:04 gitaarik

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

rcarriga avatar Apr 06 '24 14:04 rcarriga

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.

gitaarik avatar Apr 06 '24 14:04 gitaarik

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,
})

kiyoon avatar Jun 11 '24 06:06 kiyoon