clipboard-image.nvim icon indicating copy to clipboard operation
clipboard-image.nvim copied to clipboard

[Enhancement] Should Allow Use Multiple "%s" and Quotes `"` in Affix

Open Bekaboo opened this issue 2 years ago • 3 comments

First of all thank you for this awesome plugin! :smile:

This plugin makes markdown editing with neovim much more convenient, but currently I find it difficult to set strings with multiple "%s" or with quotes as affix, for example, I cannot set

affix = [[<center><img src="%s" alt="%s" style="zoom: 80%" /></center>]]

Clipboard-image will complain:

image

if I set affix as shown.

Bekaboo avatar Jul 03 '22 15:07 Bekaboo

Thank you for liking my plugin!

I've been thinking about adding support for multiple text placeholder but as of now I haven't found a nice way to implement it. Since the second %s is not always to be alt message. Like in markdown where the first %s is the alt message.

For now, you can do like what I did in this discussion.

require("clipboard-image").setup {
  markdown = {
    affix = [[<center><img src="%s" alt="" style="zoom: 80%%" /></center>]],
    img_handler = function (img)
      vim.cmd("normal! 2f=l") -- go to 2nd `=` and then move right
      vim.cmd("normal! a" .. img.name)
    end
  }
}

:normal executes normal mode's key mapping, see :h :normal. Also notice you should escape 80% to be 80%%

https://user-images.githubusercontent.com/26477782/177065665-2e2abc14-5549-4541-b483-b89a4d3d694b.mp4

ekickx avatar Jul 04 '22 01:07 ekickx

Thank you for liking my plugin!

I've been thinking about adding support for multiple text placeholder but as of now I haven't found a nice way to implement it. Since the second %s is not always to be alt message. Like in markdown where the first %s is the alt message.

For now, you can do like what I did in this discussion.

require("clipboard-image").setup {
  markdown = {
    affix = [[<center><img src="%s" alt="" style="zoom: 80%%" /></center>]],
    img_handler = function (img)
      vim.cmd("normal! 2f=l") -- go to 2nd `=` and then move right
      vim.cmd("normal! a" .. img.name)
    end
  }
}

:normal executes normal mode's key mapping, see :h :normal. Also notice you should escape 80% to be 80%% Kooha-07-04-2022-07-59-59.mp4

Thanks for your reply, that works!

By the way, what is the desktop environment and the screenshot app shown in the record? They look nice. I'm just moving from windows to manjaro and currently looking for an alternative to snipaste (a powerful and convenient screenshot tool on windows & mac, linux version is "on the way" but seems that the developers have given up or have meet some serious problems with that :-( ). I've tried flameshot but that does not satisfy me.

Bekaboo avatar Jul 04 '22 16:07 Bekaboo

By the way, what is the desktop environment and the screenshot app shown in the record?

It's a built-in feature from GNOME 42

I've tried flameshot but that does not satisfy me.

Tbh it's not that powerful, I think flameshot is better than this tool

ekickx avatar Jul 04 '22 18:07 ekickx

I will close this issue since there's no further discussion.

ekickx avatar Nov 09 '22 11:11 ekickx