dotfiles/nvim/.config/nvim/lua/plugins/prose.lua
Marty Oehme b2c64a0925
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`.
2024-06-16 21:36:57 +02:00

184 lines
5.1 KiB
Lua

local writing_ft = { "quarto", "pandoc", "markdown", "text", "tex", "typst" }
local prose_plugs = {
-- UI improvements
-- provide distraction free writing
{
"folke/zen-mode.nvim",
config = true,
cmd = { "ZenMode" },
dependencies = { "folke/twilight.nvim" },
keys = { { "<leader>sz", ":ZenMode<cr>", silent = true, desc = "toggle zen mode" } },
},
{
"andrewferrier/wrapping.nvim",
opts = {
create_keymappings = false,
notify_on_switch = false,
softener = { quarto = true, markdown = true, text = true, asciidoc = true },
auto_set_mode_filetype_allowlist = {
"asciidoc",
"gitcommit",
"latex",
"mail",
"markdown",
"rst",
"tex",
"text",
"quarto",
},
},
event = { "BufReadPre", "BufNewFile" },
keys = {
{
"<localleader>sw",
function()
require("wrapping").toggle_wrap_mode()
end,
silent = true,
desc = "toggle wrap mode",
},
},
},
-- displays prettier headlines mimicking the ones in emacs orgmode
{
"lukas-reineke/headlines.nvim",
dependencies = "nvim-treesitter/nvim-treesitter",
config = true,
ft = writing_ft,
},
-- generate an auto-updating html preview for md files
-- uses the very nice peek if deno is available, otherwise falls back to markdown-preview
{
"toppair/peek.nvim",
event = { "VeryLazy" },
cond = vim.fn.executable("deno") == 1,
build = "deno task --quiet build:fast",
config = function()
require("peek").setup()
vim.api.nvim_create_user_command("PeekOpen", require("peek").open, {})
vim.api.nvim_create_user_command("PeekClose", require("peek").close, {})
end,
},
{
"iamcco/markdown-preview.nvim",
cond = vim.fn.executable("deno") == 0,
build = function()
vim.fn["mkdp#util#install"]()
end,
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
{
"mickael-menu/zk-nvim",
config = function()
if require("core.util").is_available("which-key") then
local prefix = require("which-key").register
prefix({ ["<leader>n"] = { name = "+notes" } })
prefix({ ["<localleader>n"] = { name = "+note" } })
prefix({ ["<localleader>n"] = { name = "+note", mode = "v" } })
require("zk.commands").add("ZkOrphans", function(opts)
opts = vim.tbl_extend("force", { orphan = true }, opts or {})
require("zk").edit(opts, { title = "Zk Orphans" })
end)
end
require("zk").setup({
picker = "telescope",
lsp = {
auto_attach = {
enabled = true,
filteypes = { "markdown", "quarto" },
},
},
})
end,
ft = writing_ft,
cmd = {
"ZkBacklinks",
"ZkCd",
"ZkIndex",
"ZkInsertLink",
"ZkInsertLinkAtSelection",
"ZkLinks",
"ZkMatch",
"ZkNew",
"ZkNewFromContentSelection",
"ZkNewFromTitleSelection",
"ZkNotes",
"ZkTags",
"ZkOrphans",
},
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>nn", "<cmd>ZkNotes { sort = { 'modified' } }<cr>", desc = "note list" },
{
"<leader>nf",
"<Cmd>ZkNotes { sort = { 'modified' }, match = { vim.fn.input('Search: ') } }<CR>",
desc = "note search",
},
{ "<leader>nf", "<cmd>ZkMatch<cr>", desc = "find note from selection", mode = "v" },
{ "<leader>nt", "<cmd>ZkTags<cr>", desc = "note tags" },
{ "<leader>nc", "<cmd>ZkCd<cr>", desc = "notedir cd" },
{ "<leader>no", "<cmd>ZkNotes { sort = { 'modified' } }<cr>", desc = "orphans list" },
{ "<leader>nl", "<cmd>ZkLinks<cr>", desc = "note links" },
{ "<leader>nb", "<cmd>ZkBacklinks<cr>", desc = "note backlinks" },
{ "<localleader>nn", "<cmd>ZkNew { title = vim.fn.input('Title: ') }<cr>", desc = "new note" },
{ "<localleader>nn", ":'<,'>ZkNewFromTitleSelection<cr>", desc = "new note from selection", mode = "v" },
{ "<localleader>nN", ":'<,'>ZkNewFromContentSelection<cr>", desc = "content from selection", mode = "v" },
},
},
-- syntax highlighting for markdown criticmarkup (comments, additions, ...)
{ "vim-pandoc/vim-criticmarkup", ft = writing_ft },
-- create mindmaps from your markdown
{
"Zeioth/markmap.nvim",
cmd = { "MarkmapOpen", "MarkmapSave", "MarkmapWatch", "MarkmapWatchStop" },
config = true,
},
-- cite as you write from papis databases
-- ADDITIONAL DEPENDENCIES: papis and yq in shell env
-- {
-- "jghauser/papis.nvim",
-- dependencies = {
-- "kkharji/sqlite.lua",
-- "MunifTanjim/nui.nvim",
-- "pysan3/pathlib.nvim",
-- "nvim-neotest/nvim-nio",
-- "nvim-treesitter/nvim-treesitter",
-- },
-- cond = vim.fn.executable("papis") == 1 and vim.fn.executable("yq") == 1,
-- ft = writing_ft,
-- lazy = false,
-- config = function()
-- require("papis").setup({})
-- end,
-- },
}
return prose_plugs