nvim: Use peek for markdown preview where possible

On machines that have deno installed, we use peek instead of
markdown-preview for html-based previews of md files. The preview is
more responsive and in a neater package, as well as just not relying on
any vim plugin stuff to the same degree.
We still fall back to the old markdown-preview if no deno executable is
available.

We also change the key maps slightly to prepare for future 'prose' or
'preview' based mappings: All mappings are registered under the
`<leader>p` layer, with md preview being `<leader>pp` and various
mindmap operations moved to `<leader>pm`.
This commit is contained in:
Marty Oehme 2024-06-06 20:50:37 +02:00
parent b69548fa38
commit 1771a61334
Signed by: Marty
GPG key ID: EDBF2ED917B2EF6A
2 changed files with 33 additions and 5 deletions

View file

@ -8,7 +8,7 @@ local prose_plugs = {
config = true,
cmd = { "ZenMode" },
dependencies = { "folke/twilight.nvim" },
keys = { { "<leader>sz", ":ZenMode<cr>", { silent = true } } },
keys = { { "<leader>sz", ":ZenMode<cr>", silent = true, desc = "toggle zen mode" } },
},
{
"andrewferrier/wrapping.nvim",
@ -48,8 +48,21 @@ local prose_plugs = {
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,