Code Monkey home page Code Monkey logo

clipboard-image.nvim's Introduction

Clipboard Image ๐Ÿ“‹๐Ÿ–ผ๏ธ


License

Installation โ€ข Usage & Demo โ€ข Config


Install

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

โ„น๏ธ Run :checkhealth clipboard-image to check a missing dependency

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:

Example
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,
  }
}
Structure

See also API

{
  default = {
    <options>
  },
  <filetype> = {
    <options>
  },
}
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
img_handler function(img) end Function that will handle image after pasted.
img is a table that contain pasted image's name and path
affix default: "%s"
markdown: "![](%s)"
asciidoc: "image::%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

clipboard-image.nvim's People

Contributors

ekickx avatar huynle avatar axieax avatar geier avatar gokulmaxi avatar jakobkhansen avatar jqfeld avatar codiy1992 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.