nvim: Allow pasting images into markup files

With the new `img-clip.nvim` extension we can copy any image anywhere
and simply paste it into a markdown/quarto/latex/typst/... document with
the right markup already.

Those can be from the web/locally. Also allows drag and drop from e.g.
web pages.

Mapped to `<leader>pp` currently, though we will have to find a better
mapping. Or invoked with `:ImagePaste`.
This commit is contained in:
Marty Oehme 2024-06-16 21:34:52 +02:00
parent 3b1a874883
commit b2c64a0925
Signed by: Marty
GPG key ID: EDBF2ED917B2EF6A
3 changed files with 25 additions and 3 deletions

View file

@ -35,9 +35,9 @@ if require("core.util").is_available("peek") then
peek.open() peek.open()
end end
end end
map("n", "<leader>pp", togglePeek, { desc = "show md preview" }) map("n", "<leader>po", togglePeek, { desc = "show md preview" })
else else
map("n", "<leader>pp", "<Plug>MarkdownPreviewToggle", { desc = "show md preview" }) map("n", "<leader>po", "<Plug>MarkdownPreviewToggle", { desc = "show md preview" })
end end
-- create mindmaps directly from markdown! requires external executable -- create mindmaps directly from markdown! requires external executable

View file

@ -35,6 +35,7 @@
"glance.nvim": { "branch": "master", "commit": "51059bcf21016387b6233c89eed220cf47fca752" }, "glance.nvim": { "branch": "master", "commit": "51059bcf21016387b6233c89eed220cf47fca752" },
"headlines.nvim": { "branch": "master", "commit": "618ef1b2502c565c82254ef7d5b04402194d9ce3" }, "headlines.nvim": { "branch": "master", "commit": "618ef1b2502c565c82254ef7d5b04402194d9ce3" },
"image.nvim": { "branch": "master", "commit": "da64ce69598875c9af028afe129f916b02ccc42e" }, "image.nvim": { "branch": "master", "commit": "da64ce69598875c9af028afe129f916b02ccc42e" },
"img-clip.nvim": { "branch": "main", "commit": "fc30500c35663aa1762697f5aba31d43b86028f0" },
"jupytext.nvim": { "branch": "main", "commit": "c8baf3ad344c59b3abd461ecc17fc16ec44d0f7b" }, "jupytext.nvim": { "branch": "main", "commit": "c8baf3ad344c59b3abd461ecc17fc16ec44d0f7b" },
"lazy.nvim": { "branch": "main", "commit": "fafe1f7c640aed75e70a10e6649612cd96f39149" }, "lazy.nvim": { "branch": "main", "commit": "fafe1f7c640aed75e70a10e6649612cd96f39149" },
"lsp-setup.nvim": { "branch": "main", "commit": "6e4e977512ce426d8b52c27f3b6e6aefc73e1452" }, "lsp-setup.nvim": { "branch": "main", "commit": "6e4e977512ce426d8b52c27f3b6e6aefc73e1452" },

View file

@ -1,4 +1,4 @@
local writing_ft = { "quarto", "pandoc", "markdown", "text", "tex" } local writing_ft = { "quarto", "pandoc", "markdown", "text", "tex", "typst" }
local prose_plugs = { local prose_plugs = {
-- UI improvements -- UI improvements
@ -69,6 +69,26 @@ local prose_plugs = {
ft = writing_ft, ft = writing_ft,
}, },
-- easy copy paste of images into markup files
{
"HakonHarnes/img-clip.nvim",
event = "VeryLazy",
opts = {
filetypes = {
quarto = {
url_encode_path = true,
template = "![$CURSOR]($FILE_PATH)",
download_images = false,
},
},
},
cmd = { "PasteImage" },
keys = {
{ "<leader>pp", "<cmd>PasteImage<cr>", desc = "Paste image from system clipboard" },
},
ft = writing_ft,
},
-- bring zettelkasten commands -- bring zettelkasten commands
{ {
"mickael-menu/zk-nvim", "mickael-menu/zk-nvim",
@ -111,6 +131,7 @@ local prose_plugs = {
"ZkOrphans", "ZkOrphans",
}, },
keys = { keys = {
-- additional key instpirations https://github.com/al1-ce/MonolithVim/blob/master/after/ftplugin/markdown.lua
{ "<leader>ni", "<cmd>edit ~/documents/notes/index.md<cr>", desc = "open index", silent = true }, { "<leader>ni", "<cmd>edit ~/documents/notes/index.md<cr>", desc = "open index", silent = true },
{ "<leader>nn", "<cmd>ZkNotes { sort = { 'modified' } }<cr>", desc = "note list" }, { "<leader>nn", "<cmd>ZkNotes { sort = { 'modified' } }<cr>", desc = "note list" },
{ {