dotfiles/nvim/.config/nvim/lua/plugins/prose.lua
Marty Oehme b0ed357037
nvim: Move switch options from ]o to ]s maps
Function is the same, `]s` for [S]witching something 'off', and `]s` for
[S]witching something on.
2025-06-12 12:15:34 +02:00

292 lines
7.5 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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 = { { "<leader>sz", ":ZenMode<cr>", 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({ { "<localleader>p", group = "presentation" } })
end
end,
keys = {
{
"<localleader>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({ { "<localleader>p", group = "presentation" } })
end
end,
keys = {
{ "<localleader>pp", "<cmd>PasteImage<cr>", 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({
{ "<leader>n", group = "notes" },
{ "<localleader>n", group = "note" },
{ "<localleader>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
{ "<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>nw", "<cmd>ZkGrep<cr>", desc = "grep notes" },
{ "<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 = 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