Install
❗ Requirement:xclip
(X11),wl-clipboard
(Wayland),pngpaste
(MacOS)ℹ️ On Linux, do
echo $XDG_SESSION_TYPE
to check what display server you're on
Plugin manager | Script |
---|---|
vim-plug | Plug 'ekickx/clipboard-image.nvim' |
packer.nvim | use 'ekickx/clipboard-image.nvim' |
Usage
This is the basic usage. If you want to see more you can read API
Command | Demo |
---|---|
PasteImg |
![]() |
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:
require'clipboard-image'.setup {
-- Default configuration for all typefile
default = {
img_dir = "img",
img_dir_txt = "img",
img_name = function () return os.date('%Y-%m-%d-%H-%M-%S') end,
affix = "%s"
},
-- 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 `:set 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",
affix = "![](%s)"
}
}
Options | Default | Description |
---|---|---|
img_dir |
"img" |
Directory where the image from clipboard will be copied to |
img_dir_txt |
"img" |
Directory that will be inserted to buffer. Example: Your actual dir is src/assets/img but your dir on text or buffer is /assets/img |
img_name |
function () return os.date('%Y-%m-%d-%H-%M-%S') end |
Image's name |
affix |
default : "%s" markdown : "![](%s)" |
String that sandwiched the image's path |
Tips
Share your tips here
Questions
You can ask your questions on discussions
Contribute
Read the contribution guide here
Credits
Thanks to:
- ferrine/md-img-paste.vim, I look some of its code
- elianiva for giving me feedback on Vim Indonesia (Telegram group)
- all neovim lua plugin creators and its contributors, I get some inspiration from reading their code