ekickx / clipboard-image.nvim

Neovim Lua plugin to paste image from clipboard.
MIT License
309 stars 51 forks source link

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

Closed Bekaboo closed 1 year ago

Bekaboo commented 2 years ago

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.

ekickx commented 2 years ago

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

Bekaboo commented 2 years ago

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.

ekickx commented 2 years ago

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 commented 1 year ago

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