dotfiles/nvim/.config/nvim/lua/plugins/prose.lua
Marty Oehme 7b9abab298
nvim: Improve quarto syntax rendering
Removed the standalone vim-pandoc-syntax plugin since I have not really
been using its functionality for a long time. Additionally, set reduce
conceallevel in markdown and quarto files to 2 for the time being to
prevent some rendering errors (especially on headlines) when interacting
with the markdown.nvim (render-markdown) plugin.
2024-07-30 07:54:38 +02:00

212 lines
5.7 KiB
Lua

local writing_ft = { "quarto", "pandoc", "markdown", "text", "tex", "typst", "bib", "context", "rst", "vimwiki" }
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 md rendering
{
"MeanderingProgrammer/markdown.nvim",
main = "render-markdown",
opts = {
file_types = { "markdown", "quarto", "pandoc", "vimwiki" },
win_options = {
conceallevel = {
rendered = 2,
},
},
heading = {
width = "block",
},
},
name = "render-markdown", -- Only needed if you have another plugin named markdown.nvim
dependencies = { "nvim-treesitter/nvim-treesitter", "nvim-tree/nvim-web-devicons" }, -- if you prefer nvim-web-devicons
ft = writing_ft,
keys = {
{
"<leader>pp",
function()
require("render-markdown").toggle()
end,
silent = true,
desc = "toggle md rendering",
},
},
},
-- 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>pi", "<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
require("which-key").add({
{ "<leader>n", group = "notes" },
{ "<localleader>n", group = "note" },
{ "<localleader>n", group = "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>ZkNew { title = vim.fn.input('Title: ') }<cr>", desc = "new note" },
{ "<leader>nn", ":'<,'>ZkNewFromTitleSelection<cr>", desc = "new note from selection", mode = "v" },
{ "<leader>nN", ":'<,'>ZkNewFromContentSelection<cr>", desc = "content from selection", mode = "v" },
{ "<leader>nl", "<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>ZkOrphans { sort = { 'modified' } }<cr>", desc = "orphans list" },
{ "<localleader>nb", "<cmd>ZkBacklinks<cr>", desc = "note backlinks" },
{ "<localleader>nl", "<cmd>ZkLinks<cr>", desc = "note links" },
},
},
-- 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,
-- },
{
"barreiroleo/ltex_extra.nvim",
branch = "dev",
},
{ "let-def/texpresso.vim", ft = { "tex" } },
}
return prose_plugs