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

FR: add padding to the side

Open chrisgrieser opened this issue 3 years ago • 3 comments

Using this command:

lua require("notify")("Hello World")

the result currently looks like this Pasted image 2022-11-08 17 13 21

However, the padding to the top and bottom is larger than to the left; something like this would look more consistent Pasted image 2022-11-08 17 16 40

chrisgrieser avatar Nov 08 '22 16:11 chrisgrieser

I don't really want to start editing the messages in the render function, because then we'll have to deal with formatting, wrapping etc. Once anticonceal is merged, this should be possible without needing to do that.

Until then you can do add this to your own config if you're not worried about the above issues:

    render = function(bufnr, notif, highlights)
      local base = require("notify.render.base")
      local namespace = base.namespace()
      local padded_message = vim.tbl_map(function(line)
        return " " .. line
      end, notif.message)
      vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, padded_message)

      vim.api.nvim_buf_set_extmark(bufnr, namespace, 0, 0, {
        hl_group = highlights.icon,
        end_line = #notif.message - 1,
        end_col = #notif.message[#notif.message],
        priority = 50,
      })
    end,

rcarriga avatar Nov 09 '22 08:11 rcarriga

hmmm, your snippet does work for me, but I also don't think it's worth spending the time debugging when the issue would be tackled via the upstream anticonceal feature anyway. Thank for letting me know!

chrisgrieser avatar Nov 09 '22 12:11 chrisgrieser

Sure, happy to leave this open for when anticonceal is added :+1:

Reference: https://github.com/neovim/neovim/pull/9496/

rcarriga avatar Nov 11 '22 09:11 rcarriga