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.
- No dependencies
- Multiple image format supported (JPG, PNG ...)
- Easy extensibility and configuration
- Written entirely in Lua
Using packer.nvim
use 'mattdibi/incolla.nvim'
Paste screenshot from clipboard
Note: the fist time you run the
Incolla
function you'll need to grant "System Events.app" access to the destination folder.
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 toimg_name
: Image's name on diskaffix
: 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>
Thanks to: