2022-12-27 20:45:43 +01:00
|
|
|
local M = {
|
|
|
|
-- paste images from clipbaord
|
|
|
|
"ekickx/clipboard-image.nvim",
|
|
|
|
cmd = "PasteImg",
|
|
|
|
}
|
2022-09-12 13:48:29 +02:00
|
|
|
|
|
|
|
local function img_name()
|
|
|
|
vim.fn.inputsave()
|
2022-12-27 20:45:43 +01:00
|
|
|
local name = vim.fn.input("Name: ")
|
2022-09-12 13:48:29 +02:00
|
|
|
vim.fn.inputrestore()
|
|
|
|
|
2022-12-27 20:45:43 +01:00
|
|
|
if name == nil or name == "" then
|
|
|
|
return os.date("%y-%m-%d-%H-%M-%S")
|
2022-09-12 13:48:29 +02:00
|
|
|
end
|
|
|
|
return name
|
|
|
|
end
|
|
|
|
|
2022-12-27 20:45:43 +01:00
|
|
|
function M.init()
|
|
|
|
vim.keymap.set(
|
|
|
|
"n",
|
|
|
|
"<leader>p",
|
|
|
|
":PasteImg<cr>",
|
|
|
|
{ desc = "[P]aste image from clipboard" }
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
function M.config()
|
|
|
|
require("clipboard-image").setup({
|
2022-09-12 13:48:29 +02:00
|
|
|
default = {
|
2022-12-27 20:45:43 +01:00
|
|
|
img_name = img_name,
|
2022-09-12 13:48:29 +02:00
|
|
|
},
|
|
|
|
tex = {
|
|
|
|
img_dir = { "%:p:h", "img" },
|
2022-09-25 22:03:11 +02:00
|
|
|
affix = "\\includegraphics[width=\\textwidth]{%s}",
|
2022-09-12 13:48:29 +02:00
|
|
|
},
|
2022-12-27 20:45:43 +01:00
|
|
|
})
|
2022-09-12 13:48:29 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
return M
|