ekickx/clipboard-image.nvim

github github
media plugin
star 66
stars
alert-circle 0
open issues
users 3
subscribers
git-branch 3
forks
CREATED

2021-01-12

UPDATED

9 days ago

packer

require('packer').startup(function()
  use 'ekickx/clipboard-image.nvim'
end)

paq

require "paq" { 
  'ekickx/clipboard-image.nvim'
}

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

License

Installation ā€¢ Usage & Demo ā€¢ Config


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"
    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 Useful if you have use case like the demo above where img_dir set to "src/assets/img" and img_dir_txt set to "/assets/img"
img_name function () return os.date('%Y-%m-%d-%H-%M-%S') end Image's name
affix "%s" Affix

Tips

WIP

Questions

You can ask your questions on discussions

Contribute

Read the contribution guide here

Credits

Thanks to:

  • ferrine/md-img-paste.vim, I steal some code from it
  • 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