Skip to content

Neovim Lua plugin to paste images from the MacOS clipboard.

License

Notifications You must be signed in to change notification settings

mattdibi/incolla.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

82 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

incolla.nvim


License

Neovim Lua plugin to paste images from MacOS clipboard

This plugin allows for seamless clipboard image pasting inside Neovim.

It leverages AppleScript under the hood and thus require MacOS to work. Additionally this plugin requires Neovim 0.7 or higher. It makes use of Neovim only features so it will not work in Vim.

✨ Features

  • No dependencies
  • Multiple image format supported (JPG, PNG ...)
  • Easy extensibility and configuration
  • Written entirely in Lua

📦 Installation

Using packer.nvim

use 'mattdibi/incolla.nvim'

🚀 Usage

Paste screenshot from clipboard

IncollaBasic

Paste image from clipboard URL

IncollaURL

Paste image copied from the browser

IncollaBrowser

Note: the fist time you run the Incolla function you'll need to grant "System Events.app" access to the destination folder.

immagine

⚙️ Configuration

Incolla.nvim doesn't require any configuration to work out-of-the box. The default configuration is the following:

defaults = {
    img_dir = "imgs",
    img_name = function()
        return os.date("IMG-%d-%m-%Y-%H-%M-%S")
    end,
    affix = "%s",
}

Where:

  • img_dir: Directory where the image from clipboard will be copied to
  • img_name: Image's name on disk
  • affix: String that sandwiches the image's path and will be written in your open buffer

If you want to customize the behaviour of the plugin you can look at the following section.

Example

In you Neovim configuration directory, create a new file inside the after/plugin directory with the following:

require("incolla").setup {
    -- Default configuration for all filetype
    defaults = {
        img_dir = "imgs",
        img_name = function()
            return os.date('%Y-%m-%d-%H-%M-%S')
        end,
        affix = "%s",
    },
    -- You can customize the behaviour for a filetype by creating a field named after the desired filetype
    -- If you're uncertain what to name your field to, you can run `lua print(vim.bo.filetype)`
    -- Missing options from `<filetype>` field will be replaced by the default configuration
    markdown = {
        affix = "![](%s)",
    }
}

Setting your keymap

-- This maps the paste command to <leader>xp
vim.api.nvim_set_keymap('n', '<leader>xp', '', {
    noremap = true,
    callback = function()
        require'incolla'.incolla()
    end,
})
Vimscript
nnoremap <leader>xp :Incolla<CR>

🌟 Credits

Thanks to:

Releases

No releases published

Languages