Home

Awesome

<div align="center">

Clipboard Image šŸ“‹šŸ–¼ļø

</br><a href="/LICENSE.md"> License </a>

Installation ā€¢ Usage & Demo ā€¢ Config

</div>

Install

ā— Requirement: xclip (X11), wl-clipboard (Wayland), pngpaste (MacOS)

ā„¹ļø Run :checkhealth clipboard-image to check a missing dependency

Plugin managerScript
vim-plugPlug 'ekickx/clipboard-image.nvim'
packer.nvimuse 'ekickx/clipboard-image.nvim'

Usage

This is the basic usage. If you want to see more you can read API

CommandDemo
PasteImg<kbd></kbd>

Config

This plugin is zero config, means you don't need to configure anything to works. But if you want to, you can configure it like this:

<details> <summary><strong>Example</strong></summary></br>
require'clipboard-image'.setup {
  -- Default configuration for all filetype
  default = {
    img_dir = "images",
    img_name = function() return os.date('%Y-%m-%d-%H-%M-%S') end, -- Example result: "2021-04-13-10-04-18"
    affix = "<\n  %s\n>" -- Multi lines affix
  },
  -- You can create configuration for ceartain filetype by creating another field (markdown, in this case)
  -- If you're uncertain what to name your field to, you can run `lua print(vim.bo.filetype)`
  -- Missing options from `markdown` field will be replaced by options from `default` field
  markdown = {
    img_dir = {"src", "assets", "img"}, -- Use table for nested dir (New feature form PR #20)
    img_dir_txt = "/assets/img",
    img_handler = function(img) -- New feature from PR #22
      local script = string.format('./image_compressor.sh "%s"', img.path)
      os.execute(script)
    end,
  }
}
</details> <details open> <summary><strong>Structure</strong></summary></br>

See also API

{
  default = {
    <options>
  },
  <filetype> = {
    <options>
  },
}
OptionsDefaultDescription
img_dir"img"Directory where the image from clipboard will be copied to
img_dir_txt"img"Directory that will be inserted to buffer.<br> Example: Your actual dir is src/assets/img but your dir on text or buffer is /assets/img
img_namefunction() return os.date('%Y-%m-%d-%H-%M-%S') endImage's name
img_handlerfunction(img) endFunction that will handle image after pasted.<br>img is a table that contain pasted image's name and path
affixdefault: "%s"</br>markdown: "![](%s)"</br>asciidoc: "image::%s[]"String that sandwiched the image's path
</details>

Tips

Share your tips here

Questions

You can ask your questions on discussions

Contribute

Read the contribution guide here

Credits

Thanks to: