From 7698173af2dfd68fcbfcb0e95f5e72d56bdf8df7 Mon Sep 17 00:00:00 2001 From: Matthias Puchstein Date: Wed, 12 Nov 2025 20:40:00 +0100 Subject: [PATCH] added a kiss way to write md --- .config/nvim/ftplugin/markdown.lua | 5 ++ .config/nvim/lua/plugins/md-kiss.lua | 74 ++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 .config/nvim/ftplugin/markdown.lua create mode 100644 .config/nvim/lua/plugins/md-kiss.lua diff --git a/.config/nvim/ftplugin/markdown.lua b/.config/nvim/ftplugin/markdown.lua new file mode 100644 index 0000000..aef5bfe --- /dev/null +++ b/.config/nvim/ftplugin/markdown.lua @@ -0,0 +1,5 @@ +vim.opt_local.spell = true +vim.opt_local.spelllang = { "en_us", "de_de", "fr_fr" } +vim.opt_local.wrap = true +vim.opt_local.linebreak = true +vim.opt_local.conceallevel = 2 diff --git a/.config/nvim/lua/plugins/md-kiss.lua b/.config/nvim/lua/plugins/md-kiss.lua new file mode 100644 index 0000000..5c61c8c --- /dev/null +++ b/.config/nvim/lua/plugins/md-kiss.lua @@ -0,0 +1,74 @@ +-- Minimal Markdown + math workflow (FOSS/KISS): +-- - Blink completion of LaTeX symbols in Markdown +-- - :MdPdf to compile current .md -> PDF via Pandoc (LuaLaTeX) and open in Zathura +-- - Ensure Treesitter grammars for markdown + +return { + -- Extend blink.cmp sources so Markdown gets LaTeX symbol completion (inserts \alpha, not α) + { + "Saghen/blink.cmp", + optional = true, + opts = function(_, opts) + opts.sources = opts.sources or {} + opts.sources.per_filetype = vim.tbl_deep_extend("force", opts.sources.per_filetype or {}, { + markdown = { inherit_defaults = true, "latex_symbols" }, + }) + return opts + end, + }, + + -- Ensure Treesitter grammars for better Markdown editing + { + "nvim-treesitter/nvim-treesitter", + opts = function(_, opts) + opts.ensure_installed = opts.ensure_installed or {} + for _, lang in ipairs { "markdown", "markdown_inline" } do + if not vim.tbl_contains(opts.ensure_installed, lang) then table.insert(opts.ensure_installed, lang) end + end + end, + }, + + -- Add a simple :MdPdf command and a keymap + { + "AstroNvim/astrocore", + opts = { + commands = { + MdPdf = { + function() + local stem = vim.fn.expand "%:r" + local ext = vim.fn.expand "%:e" + if ext ~= "md" then + vim.notify("MdPdf: open a Markdown file (*.md)", vim.log.levels.WARN) + return + end + local cmd = { + "pandoc", + stem .. ".md", + "-o", + stem .. ".pdf", + "--from=markdown+tex_math_dollars+raw_tex", + "--pdf-engine=lualatex", + "--citeproc", + } + vim.fn.jobstart(cmd, { + detach = true, + on_exit = function() + -- Open Zathura only once per session; it will auto-reload on subsequent builds + if not vim.g._mdpdf_zathura_opened then + vim.g._mdpdf_zathura_opened = true + vim.fn.jobstart({ "zathura", "--fork", stem .. ".pdf" }, { detach = true }) + end + end, + }) + end, + desc = "Pandoc → PDF (LuaLaTeX) and open in Zathura", + }, + }, + mappings = { + n = { + ["mp"] = { "MdPdf", desc = "Markdown → PDF (Pandoc)" }, + }, + }, + }, + }, +}