local md_like = { "markdown", "djot", "pandoc", "quarto", "vimwiki", "codecompanion", } local org_like = { "norg", "org", } local prose_ft = { unpack(md_like), unpack(org_like), "asciidoc", "bib", "context", "gitcommit", "latex", "mail", "rst", "tex", "text", "typst", "rmd", } local prose_plugs = { -- UI improvements -- provide distraction free writing { "folke/zen-mode.nvim", config = true, cmd = { "ZenMode" }, dependencies = { "folke/twilight.nvim" }, keys = { { "sz", ":ZenMode", silent = true, desc = "toggle zen mode" } }, }, { "andrewferrier/wrapping.nvim", opts = { create_keymaps = false, notify_on_switch = false, -- softener = { quarto = true, markdown = true, text = true, asciidoc = true }, auto_set_mode_filetype_allowlist = prose_ft, }, -- event = { "BufReadPre", "BufNewFile" }, ft = prose_ft, keys = { { "[sw", function() require("wrapping").soft_wrap_mode() end, silent = true, desc = "soft wrap", }, { "]sw", function() require("wrapping").hard_wrap_mode() end, silent = true, desc = "hard wrap", }, }, }, -- displays prettier md rendering { "MeanderingProgrammer/render-markdown.nvim", main = "render-markdown", opts = { file_types = { "markdown", "codecompanion" }, render_modes = { "n", "c", "i" }, code = { sign = false, width = "full", position = "right", right_pad = 1, }, checkbox = { custom = { doing = { raw = "[o]", rendered = "󰡖 ", highlight = "RenderMarkdownTodo" }, indeterminate = { raw = "[-]", rendered = "󰄗 ", highlight = "RenderMarkdownTodo" }, removed = { raw = "[~]", rendered = "󱋭 ", highlight = "RenderMarkdownTodo" }, }, }, html = { comment = { conceal = false, }, }, }, name = "render-markdown", -- Only needed if you have another plugin named markdown.nvim dependencies = { "nvim-treesitter/nvim-treesitter", "nvim-tree/nvim-web-devicons", }, ft = md_like, cmd = "RenderMarkdown", init = function() if require("core.util").is_available("which-key") then require("which-key").add({ { "p", group = "presentation" } }) end end, keys = { { "pm", function() require("render-markdown").toggle() end, silent = true, desc = "toggle md rendering", }, }, }, --- PREVIEW SECTION -- 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", cond = vim.fn.executable("deno") == 1, build = "deno task --quiet build:fast", ft = md_like, opts = {}, }, { "iamcco/markdown-preview.nvim", cond = vim.fn.executable("deno") == 0, build = function() vim.fn["mkdp#util#install"]() end, version = false, ft = md_like, cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" }, }, { "chomosuke/typst-preview.nvim", ft = { "typst" }, opts = { -- to use mason-managed binary dependencies_bin = { ["tinymist"] = "tinymist" }, }, cmd = { "TypstPreview", "TypstPreviewUpdate", "TypstPreviewStop", "TypstPreviewToggle", "TypstPreviewFollowCursor", "TypstPreviewNoFollowCursor", "TypstPreviewFollowCursorToggle", }, }, --- END PREVIEW SECTION -- 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" }, init = function() if require("core.util").is_available("which-key") then require("which-key").add({ { "p", group = "presentation" } }) end end, keys = { { "pp", "PasteImage", desc = "Paste image from system clipboard" }, }, ft = prose_ft, }, -- bring zettelkasten commands { "zk-org/zk-nvim", init = function() if require("core.util").is_available("which-key") then require("which-key").add({ { "n", group = "notes" }, { "n", group = "note" }, { "n", group = "note", mode = "v" }, }) end end, config = function() require("zk.commands").add("ZkOrphans", function(opts) opts = vim.tbl_extend("force", { orphan = true }, opts or {}) require("zk").edit(opts, { title = "Zk Orphans" }) end) require("zk.commands").add("ZkGrep", function(opts) local collection = {} local list_opts = { select = { "title", "path", "absPath" } } require("zk.api").list(vim.env.ZK_NOTEBOOK_DIR, list_opts, function(_, notes) for _, note in ipairs(notes) do collection[note.absPath] = note.title or note.path end end) local search_dir = vim.env.ZK_NOTEBOOK_DIR local options = vim.tbl_deep_extend("force", { prompt = "Note Grep❯ ", -- cmd = "cd " .. search_dir .. "; rg --vimgrep", cwd = search_dir, disable_coordinates = true, path_display = function(_, path) return collection[path] end, }, opts or {}) -- FIXME: Don't hard-code this so much? -- require("telescope.builtin").live_grep(options) require("fzf-lua").live_grep(options) end) local picker = "select" if require("core.util").is_available("fzf-lua") then picker = "fzf_lua" elseif require("core.util").is_available("telescope") then picker = "telescope" end require("zk").setup({ picker = picker, lsp = { config = { filetypes = { "markdown", "quarto", "djot" }, }, auto_attach = { enabled = true, }, }, }) end, ft = prose_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 { "ni", "edit ~/documents/notes/index.md", desc = "open index", silent = true }, { "nn", "ZkNew { title = vim.fn.input('Title: ') }", desc = "new note" }, { "nn", ":'<,'>ZkNewFromTitleSelection", desc = "new note from selection", mode = "v" }, { "nN", ":'<,'>ZkNewFromContentSelection", desc = "content from selection", mode = "v" }, { "nl", "ZkNotes { sort = { 'modified' } }", desc = "note list" }, { "nf", "ZkNotes { sort = { 'modified' }, match = { vim.fn.input('Search: ') } }", desc = "note search", }, { "nf", "ZkMatch", desc = "find note from selection", mode = "v" }, { "nw", "ZkGrep", desc = "grep notes" }, { "nt", "ZkTags", desc = "note tags" }, { "nc", "ZkCd", desc = "notedir cd" }, { "no", "ZkOrphans { sort = { 'modified' } }", desc = "orphans list" }, { "nb", "ZkBacklinks", desc = "note backlinks" }, { "nl", "ZkLinks", desc = "note links" }, }, }, -- syntax highlighting for markdown criticmarkup (comments, additions, ...) { "vim-pandoc/vim-criticmarkup", ft = md_like }, -- create mindmaps from your markdown { "Zeioth/markmap.nvim", cmd = { "MarkmapOpen", "MarkmapSave", "MarkmapWatch", "MarkmapWatchStop" }, config = true, }, { "barreiroleo/ltex_extra.nvim", branch = "dev", }, { "let-def/texpresso.vim", ft = { "tex" } }, } return prose_plugs