From b2c64a092547ec23f55aba63e9da89751427be9e Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Sun, 16 Jun 2024 21:34:52 +0200 Subject: [PATCH] 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 `pp` currently, though we will have to find a better mapping. Or invoked with `:ImagePaste`. --- nvim/.config/nvim/after/ftplugin/markdown.lua | 4 ++-- nvim/.config/nvim/lazy-lock.json | 1 + nvim/.config/nvim/lua/plugins/prose.lua | 23 ++++++++++++++++++- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/nvim/.config/nvim/after/ftplugin/markdown.lua b/nvim/.config/nvim/after/ftplugin/markdown.lua index 7f2c06f..84ad5c0 100644 --- a/nvim/.config/nvim/after/ftplugin/markdown.lua +++ b/nvim/.config/nvim/after/ftplugin/markdown.lua @@ -35,9 +35,9 @@ if require("core.util").is_available("peek") then peek.open() end end - map("n", "pp", togglePeek, { desc = "show md preview" }) + map("n", "po", togglePeek, { desc = "show md preview" }) else - map("n", "pp", "MarkdownPreviewToggle", { desc = "show md preview" }) + map("n", "po", "MarkdownPreviewToggle", { desc = "show md preview" }) end -- create mindmaps directly from markdown! requires external executable diff --git a/nvim/.config/nvim/lazy-lock.json b/nvim/.config/nvim/lazy-lock.json index 5712d06..56235ac 100644 --- a/nvim/.config/nvim/lazy-lock.json +++ b/nvim/.config/nvim/lazy-lock.json @@ -35,6 +35,7 @@ "glance.nvim": { "branch": "master", "commit": "51059bcf21016387b6233c89eed220cf47fca752" }, "headlines.nvim": { "branch": "master", "commit": "618ef1b2502c565c82254ef7d5b04402194d9ce3" }, "image.nvim": { "branch": "master", "commit": "da64ce69598875c9af028afe129f916b02ccc42e" }, + "img-clip.nvim": { "branch": "main", "commit": "fc30500c35663aa1762697f5aba31d43b86028f0" }, "jupytext.nvim": { "branch": "main", "commit": "c8baf3ad344c59b3abd461ecc17fc16ec44d0f7b" }, "lazy.nvim": { "branch": "main", "commit": "fafe1f7c640aed75e70a10e6649612cd96f39149" }, "lsp-setup.nvim": { "branch": "main", "commit": "6e4e977512ce426d8b52c27f3b6e6aefc73e1452" }, diff --git a/nvim/.config/nvim/lua/plugins/prose.lua b/nvim/.config/nvim/lua/plugins/prose.lua index d6c6327..7dfbbaa 100644 --- a/nvim/.config/nvim/lua/plugins/prose.lua +++ b/nvim/.config/nvim/lua/plugins/prose.lua @@ -1,4 +1,4 @@ -local writing_ft = { "quarto", "pandoc", "markdown", "text", "tex" } +local writing_ft = { "quarto", "pandoc", "markdown", "text", "tex", "typst" } local prose_plugs = { -- UI improvements @@ -69,6 +69,26 @@ local prose_plugs = { 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 = { + { "pp", "PasteImage", desc = "Paste image from system clipboard" }, + }, + ft = writing_ft, + }, + -- bring zettelkasten commands { "mickael-menu/zk-nvim", @@ -111,6 +131,7 @@ local prose_plugs = { "ZkOrphans", }, keys = { + -- additional key instpirations https://github.com/al1-ce/MonolithVim/blob/master/after/ftplugin/markdown.lua { "ni", "edit ~/documents/notes/index.md", desc = "open index", silent = true }, { "nn", "ZkNotes { sort = { 'modified' } }", desc = "note list" }, {